ListView overlaps textview and background image in android - android

I am trying to design layout but its not rendering properly. Background logo is not visible at all. When phone goes to landscape mode then textview below listview is not visible.
Below is my xml.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#E0ECF8" >
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/note1"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/banner640" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/menu_title"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8" >
</ListView>
<View
android:id="#+id/View2_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#android:id/list"
android:layout_marginTop="5dp"
android:background="#80000000" />
</RelativeLayout>
</ScrollView>

You problem may come from using ListView inside ScrollView. You should avoid it. To overcome your problem, I think you can set a specific height for your ListView or using a vertical LinearLayout to add row views programmatically.
Using a ListView to make it not scroll is extremely expensive and goes against the whole purpose of ListView. You should NOT do this. Just use a LinearLayout instead. - from Romain Guy - the developer who write ListView in GG.

ok the problem is there with your definition, just define your LinearLayout below View (which is belowListView). check this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="MEnu"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8" >
</ListView>
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginTop="10dp"
android:background="#E0ECF8"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="Nofghnjfgjtyjjyjdtyjte"
android:textColor="#000"
android:textSize="25sp" />
</LinearLayout>
</RelativeLayout>
output :

May be that is what you need?
UPDATE:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#E0ECF8"
android:fillViewport="true"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.view.MainMenuActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#E0ECF8" >
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/View1_hr"
android:layout_marginTop="0dp"
android:background="#E0ECF8"
android:layout_above="#+id/note1Wrapper_note1">
</ListView>
<LinearLayout
android:id="#+id/note1Wrapper_note1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="start"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="start"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2_note1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/note1"
android:textColor="#000"
android:textSize="13sp" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#0c2d4e"
android:src="#drawable/banner640" />
<TextView
android:id="#+id/textView1_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="#string/menu_title"
android:textColor="#000"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:id="#+id/View1_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#+id/textView1_title"
android:layout_marginTop="15dp"
android:background="#80000000" />
<View
android:id="#+id/View2_hr"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_below="#android:id/list"
android:layout_marginTop="5dp"
android:background="#80000000" />
</RelativeLayout>
</ScrollView>

Related

How to place two Seeksbars at one place?

Here what I am doing is , I want to show the seekbar running in between the RangeSeekBar (between the selected range). For that, I want to place these two seekbars at one position.
I don't know how to do that. I have tried RelativeLayout and FrameLayout but nothing happened.
Thank you.
activity_play.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity">
<SeekBar
android:id="#+id/pSeekBar"
android:layout_width="match_parent"
android:layout_height="37dp" />
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/screen_background_light"
android:orientation="vertical"
android:padding="10dip">
<TextView
android:id="#+id/selectedfile"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center_horizontal"
android:singleLine="true"
android:text="Not file selected"
android:textColor="#android:color/black" />
<com.yahoo.mobile.client.android.util.rangeseekbar.RangeSeekBar
android:id="#+id/rangeSeekBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
android:paddingBottom="10dip"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#android:drawable/screen_background_light"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/MinEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:id="#+id/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_previous" />
<ImageButton
android:id="#+id/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_play" />
<ImageButton
android:id="#+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/ic_media_next" />
<EditText
android:id="#+id/MaxEdiText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
u can use this library its hard to write it yourself
https://github.com/syedowaisali/crystal-range-seekbar

Unable to place view below RecyclerView

I'm having trouble placing an Adview below a RecyclerView. Currently the RecyclerView is taking up the rest of the layout and the Adview isn't being shown. None of the solutions I have found online have solved my issue. Usually layout_weight or layout_below solves the problem but it isn't in this case.
XML
<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"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7c7c7c"
android:focusable="true"
android:focusableInTouchMode="true">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#drawable/bordershadow2"
android:paddingBottom="17dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/recycler_view"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/bordershadow"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:entries="#array/type_array"
android:textSize="#dimen/title_size" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_race_array"
android:textSize="#dimen/title_size" />
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_affinity_array"
android:textSize="#dimen/title_size" />
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:entries="#array/sort_array"
android:textSize="#dimen/title_size" />
</TableRow>
</TableLayout>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
I had a view that needed to be under a recycler view with dynamic size.
meaning that the view supposes to move down as the RecyclerView grew.
my solution was to add paddingBottom to the RecyclerView and then negative marginTop in the same value to the view, it worked perfectly.
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:paddingBottom="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_marginTop="-48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
I rewrote your layout file, The recycleview is wrapped inside a linearlayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="12dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingBottom="20dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:background="#000000"
android:layout_height="60dp"
android:layout_below="#+id/wrapper"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/adView"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0" />
</TableRow>
</TableLayout>
</RelativeLayout>
The result is as show
If your recycleview content will extend beyond the display height then you should consider dividing your layout into partitions with android:layout_weight.
Update
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/relContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TableLayout
android:id="#+id/purchaseTableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:layout_alignParentTop="true"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingLeft="2dp"
android:singleLine="true"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/typeSpinner"
style="style/Theme.Material"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical" />
</TableRow>
</TableLayout>
<EditText
android:id="#+id/searchEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/purchaseTableLayout"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'() "
android:hint="Search"
android:imeOptions="actionDone"
android:singleLine="true" />
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/searchEditText"
android:paddingBottom="7dp"
android:paddingTop="7dp"
android:stretchColumns="0,1,2">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3.0">
<Spinner
android:id="#+id/sortRaceSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortAffinitySpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"/>
<Spinner
android:id="#+id/sortSpinner"
style="style/Theme.Material"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0" />
</TableRow>
</TableLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#color/colorPrimary"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/wrappers"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</LinearLayout>
Try adding the android:clipToPadding="false" attribute to your RecyclerView.
The official documentation says, about clipToPadding:
Sets whether this ViewGroup will clip its children to its padding and
resize (but not clip) any EdgeEffect to the padded region, if padding
is present.
By default, children are clipped to the padding of their parent
ViewGroup. This clipping behavior is only enabled if padding is
non-zero.
Your XML layout would end up being:
layout.xml
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relContainer"
android:background="#drawable/bordershadow2"
android:clipToPadding="false"
android:paddingBottom="20dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="10dp" />
You can do it other way, put the Adview on the recycler at the bottom and then in the adapter add an empty ViewHolder which will be always your last element, you can use for it an empty layout with the height of Adview.

how to set listview in half screen on Map view in android

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/contact_relMainHeader"
android:layout_width="match_parent"
android:layout_height="55dip"
android:background="#00ad9a"
android:padding="5dp" >
<ImageView
android:id="#+id/contact_btnMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginBottom="9dip"
android:layout_marginTop="9dip"
android:src="#drawable/backbutton" />
<ImageView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginBottom="3dip"
android:layout_marginTop="3dip"
android:gravity="center"
android:src="#drawable/centertext" />
</RelativeLayout>
<LinearLayout
android:id="#+id/Llayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/contact_relMainHeader"
android:background="#android:color/transparent"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/Rlayout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/contact_linearHeader1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.lociiapp.MapWrapperLayout
android:id="#+id/map_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<TextView
android:id="#+id/lastSeenDatetextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal"
android:background="#07000000"
android:gravity="bottom">
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
<TextView
android:id="#+id/typing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
</com.lociiapp.MapWrapperLayout>
</LinearLayout>
<com.lociiapp.utils.RoundedImageView
android:id="#+id/recciverImage"
android:layout_width="60dip"
android:layout_height="60dip"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/imge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/llout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Rlayout"
android:gravity="bottom"
android:orientation="horizontal" >
<EditText
android:id="#+id/txt_inputText"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_weight="0.86"
android:background="#drawable/backgroundline"
android:focusableInTouchMode="true"
android:hint="Write Message"
android:paddingLeft="20dp"
android:textColor="#ababab" />
<Button
android:id="#+id/btn_Send"
android:layout_width="79dp"
android:layout_height="50dip"
android:background="#ededed"
android:text="Send"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
This is my XMl i am trying to display listview in half screen and then it should scroll its item basically i want to display only 3 item .
currently my screen is looking like this
while i have to display list-view only half screen please tell suggest me where am doing wrong i have to display listview half screen in which i want to display only 3 item ...
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#07000000"
android:gravity="bottom"
android:orientation="horizontal" >
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</ListView>
<TextView
android:id="#+id/typing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000" />
</LinearLayout>
replace this and set ur height of linear layout according to given screen and enjoy!!!

Center text in TextView and Button

I am trying to center the text in my TextView and Button. I currently have the following code:
<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"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="#string/CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:src="#drawable/coupon" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="#string/continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
</RelativeLayout>
However, the text in the Button and TextView are to the right and hence some of the text is off the screen... I am also getting the following warning for my LinearLayout:
This LinearLayout layout or its RelativeLayout parent is possibly useless
Any help would be greatly appreciated!!
Try this
[<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.15"
android:gravity="center"
android:hint="asdasasdasdd"
android:text="adasdasdasd"
android:textAlignment="gravity"
android:textColor="#FFffff"
android:textSize="30sp"
android:typeface="monospace" />]
Try this,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/couponImage"
android:layout_width="wrap_content"
android:layout_weight="0.7"
android:layout_height="wrap_content"
android:src="#drawable/coupon" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:gravity="center"
android:text="continueButton"
android:textSize="30sp" />
<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="center_horizontal"
android:text="CouponFinder"
android:textColor="#FF0000"
android:textSize="30sp"
android:typeface="monospace" />
</RelativeLayout>
Try this..
<LinearLayout 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"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:src="#drawable/icon" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
You should make the RelativeLayout a LinearLayout, and get rid of the internal LinearLayout, unless you plan to make modifications and add more things inside the RelativeLayout and outside of the LinearLayout.
Try setting the layout-gravity on the items instead of gravity.
Hope this helps :)
Try this way:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:gravity="center"
android:text="CouponFinder"
android:textColor="#FF0000"
android:textSize="30sp"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:src="#drawable/icon" />
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.15"
android:gravity="center"
android:text="continueButton"
android:textSize="30sp" />
</LinearLayout>
The warning is because you are using only one LinearLayout as the Child View for RelativeLayout.So remove your RelativeLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:gravity="center"
android:text="#string/CouponFinder"
android:textSize="30sp"
android:textColor="#FF0000"
android:typeface="monospace" />
<ImageView
android:id="#+id/couponImage"
android:layout_width="match_parent"
android:layout_weight="0.7"
android:layout_height="0dp"
android:text="#string/CouponFinder" />
<Button
android:id="#+id/button1"
android:layout_width="match_parent"
android:layout_weight="0.15"
android:layout_height="0dp"
android:text="#string/continueButton"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
Try the above data.I got this by the above data
What you've done is correct, but to see the changes, you just need to restart your IDE. I found the answer here.

alignParentBottom not used

I had a layout which used LinearLayouts instead of RelativeLayouts. I want to add the borderless buttons to my layouts as shown here: How to create standard Borderless buttons (like in the design guidline mentioned)?
So, to use this, I had to change my LinearLayouts to RelativeLayouts. This has worked fine for the most part. However, when I try to use the alignParentBottom for one of the RelativeLayouts it doesn't work - it just overlaps with one of my other buttons.
This is my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".xxx" >
<com.xxx.xxx.customedittext
android:id="#+id/qn_et_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:drawableRight="#drawable/delete"
android:hint="#string/qn_et_title_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="5dp" />
<com.xxx.xxx.customedittext
android:id="#+id/qn_et_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/qn_et_title"
android:drawableRight="#drawable/delete"
android:hint="#string/qn_et_body_hint"
android:inputType="textCapSentences|textMultiLine" />
<CheckBox
android:id="#+id/qn_cb_ongoing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_et_body"
android:text="#string/qn_cb_ongoing" />
<Button
android:id="#+id/qn_b_create"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_cb_ongoing"
android:text="#string/qn_b_create" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="?android:attr/dividerVertical" />
<View
android:id="#+id/ViewColorPickerHelper"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="?android:attr/dividerVertical" />
<Button
android:id="#+id/BtnColorPickerCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/cancel" />
<Button
android:id="#+id/BtnColorPickerOk"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/ok" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
EDIT: This is updated code. The ScrollView overlaps the 48dp RelativeView:
<?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="wrap_content"
android:paddingBottom="3dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".QuickNoteFragment" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/qn_et_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/qn_et_title_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="5dp" />
<EditText
android:id="#+id/qn_et_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/qn_et_title"
android:hint="#string/qn_et_body_hint"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="10dp" />
<CheckBox
android:id="#+id/qn_cb_ongoing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/qn_et_body"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/qn_cb_ongoing" />
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="?android:attr/dividerVertical" />
<View
android:id="#+id/ViewColorPickerHelper"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="?android:attr/dividerVertical" />
<Button
android:id="#+id/qn_b_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#android:string/cancel" />
<Button
android:id="#+id/qn_b_create"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#id/ViewColorPickerHelper"
android:background="?android:attr/selectableItemBackground"
android:text="#string/qn_b_create" />
</RelativeLayout>
</RelativeLayout>
Use the following properties on the ScrollView:
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true">
<!-- rest of the code -->
</RelativeLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/bottom"
android:layout_alignParentTop="true" >
<!-- rest of the code -->
</ScrollView>
<RelativeLayout>

Categories

Resources