I have the following code....and I can't seem to get the ads to run outside my scroll view. I have tried to follow other questions on this topic. please assist. All of my adds are showing on top of my content. I would prefer the ads run outside my scroll view.
my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxxxxxx"
ads:loadAdOnCreate="true" />
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layoutbottom"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:padding="5dp" >
<!-- android:layout_height="456dp" -->
<TextView
android:id="#+id/txtPlaceName"
style="#style/HeaderText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txtAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txtStory"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txtURL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try adding android:layout_alignParentTop="true" on your AdView and android:layout_below="#id/adView" on your ScrollView.
Related
very new to coding atm and have this error can anyone help me please.
enter code here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RelativeLayout
android:padding="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:id="#+id/movieImageID"
android:background="#android:color/background_dark"
android:layout_width="90dp"
android:layout_height="90dp" />
<TextView
android:id="#+id/movieTitleID"
android:padding="5dp"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#id/movieImageID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Movie Title"
android:textStyle="bold" />
<TextView
android:id="#+id/movieReleaseID"
android:padding="5dp"
android:layout_toRightOf="#id/movieImageID"
android:text="Released"
android:layout_below="#id/movieTitleID"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/movieCatID"
android:padding="5dp"
android:layout_below="#id/movieReleaseID"
android:layout_toRightOf="#id/movieImageID"
android:text="Category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
</androidx.cardview.widget.Cardview>
</LinearLayout>
error i get:-AndroidStudioProjects\MovieDirectory\app\src\main\res\layout\movie_row.xml:53: AAPT: error: mismatched tag.
i manage to fix one error and get another so any help greatly appriciated.
The issue is that you are closing the CardView and RelativeLayout
instead of wrapping the children views inside them. The issue is with the tags. Check the comments in the solution.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <!--Issue here Change from /> to > -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"> <!-- Issue here Change from /> to > -->
<ImageView
android:id="#+id/movieImageID"
android:layout_width="90dp"
android:layout_height="90dp"
android:background="#android:color/background_dark" />
<TextView
android:id="#+id/movieTitleID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#id/movieImageID"
android:padding="5dp"
android:text="Movie Title"
android:textStyle="bold" />
<TextView
android:id="#+id/movieReleaseID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/movieTitleID"
android:layout_centerHorizontal="true"
android:layout_toRightOf="#id/movieImageID"
android:padding="5dp"
android:text="Released" />
<TextView
android:id="#+id/movieCatID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/movieReleaseID"
android:layout_toRightOf="#id/movieImageID"
android:padding="5dp"
android:text="Category" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
This my code in this I have been using scrollView and inside it two textViews to add more content but it is working only when there is one textView please what changes i do to add more content?And here I want space between those textViews(content) but in my code i am trying for that but the content is overlapped and there is no proper space between contents.please help me..!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hp.kludge.AndroidActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:weightSum="1">
<TextView
android:id="#+id/tvA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="ANDROID"
android:textColor="#f6080101"
android:textColorHighlight="#df1425"
android:textSize="35dp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:background="#e62027"
android:layout_height="2dp"
android:layout_below="#+id/tvC" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/scrollView"
android:fillViewport="true"
android:orientation="vertical">
<TextView
android:id="#+id/tvWhat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/tvC"
android:layout_marginTop="44dp"
android:text="What is Android?"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Content"
android:id="#+id/tvt" />
</ScrollView>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/butNext"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#abc3fb" />
</RelativeLayout>
I would like to align the view element in the current layout with the view element which I included through tag in Android.
Layout1: (Layout1.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/click_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/desc"
android:padding="4dp"
android:src="#drawable/icon_click" />
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="bottom"
android:paddingLeft="8dp"
android:paddingTop="6dp"
android:text="#string/textview1"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:text="#string/textView2"
/>
</RelativeLayout>
</LinearLayout>
Layout2:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include
android:id="#+id/includedLayout"
layout="#layout/Layout1" />
<View
android:id="#+id/seperator"
android:layout_width="wrap_content"
android:layout_height="1dp"
android:alpha="0.3"
android:background="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- I want to align this layout with relative layout present in the
Layout1.xml file which is included above -->
</LinearLayout>
</LinearLayout>
I want to align the second LinearLayout in the Layout2.xml with the RelativeLayout in the Layout1.xml file which is included in the Layout2.xml file.
Please let me know if anyone knows the solution.
Thanks.
whay dont you try putting the layout part that you want to align in to another file and only include that file in to the your layout2.xml and manually coding remining part in the layout2.xml.
What i mean is to take
`
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:gravity="bottom"
android:paddingLeft="8dp"
android:paddingTop="6dp"
android:text="#string/textview1"
/>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:text="#string/textView2"
/>
</RelativeLayout>`
this part in to another separate file and manually add imageview in to layout2.xml
I will try to represent the desired layout using text:
Stock Name
==========
symbol | score
GOOG | 76
symbol and GOOG should be in a single vertical Linear layout to group them and they should be aligned to the left score and 76 should also be in a a single vertical Linear layout to group them but they should be aligned to the right.
This is my layout. I could achieve it by the way you can see below. Does anyone got an idea what I am doing wrong? (this is only the relevant portion of the layout)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/stock_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40dp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_symbol" />
<TextView
android:id="#+id/stock_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_score" />
<TextView
android:id="#+id/stock_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</LinearLayout>
</RelativeLayout>
I also tried using android:layout_alignLeft="#+id/relative_layout" and android:layout_alignRight="#+id/relative_layout" inside the LinearLayout but without success.
I found the error thanks to #RobinHood from the chat room "Android-People":
I had to replace the inner LinearLayouts with RelativeLayout and the inner RelariveLayout should change from android:layout_width="fill_parent" to android:layout_width="wrap_content"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/stock_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_symbol" />
<TextView
android:id="#+id/stock_symbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/stock_score" />
<TextView
android:id="#+id/stock_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp" />
</RelativeLayout>
</RelativeLayout>
I have one scroll view and but while I am running the code I found that some items in top are hides.
I want to show this scroll view from top most. please help me.
code is here
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:scrollX="0px">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="#+id/img_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/logo"
android:focusable="true"
android:layout_marginTop="1dip" />
<ImageView
android:id="#+id/img_logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/jvdbanner" />
<ListView
android:id="#+id/main_list"
android:layout_width="fill_parent"
android:layout_height="279dip"
android:background="#84CFE7"
android:cacheColorHint="#00000000"
android:divider="#000000"
android:dividerHeight="1dip"
android:focusable="false"
android:fadingEdge="none"
android:scrollbars="none" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginTop="5dip"
android:background="#ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dip"
android:text="Copyright # 2012- JVD Properties, Inc."
android:textColor="#ffffff"
android:textSize="13sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dip"
android:text="All Rights Reserved."
android:textColor="#ffffff"
android:textSize="13sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Just Try this code..hope it works for you
final ScrollView main = (ScrollView) findViewById(R.id.scrollView1);
main.post(new Runnable() {
public void run() {
main.scrollTo(0,0);
}
});