Here is my xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/small_margin"
android:layout_marginRight="#dimen/small_margin"
android:background="#android:color/transparent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:background="#android:color/transparent"
android:id="#+id/nested_scrollview"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginBottom="#dimen/medium_margin"
android:background="#drawable/button_layout_progress_fragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="#dimen/medium_margin"
android:layout_marginRight="#dimen/small_margin"
android:layout_marginLeft="#dimen/small_margin"
android:layout_marginBottom="#dimen/small_margin">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="Time spent:"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_marginRight="#dimen/small_margin"/>
<TextView
android:textColor="#android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="2hrs 37 mins" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="#dimen/small_margin"
android:layout_marginLeft="#dimen/small_margin"
android:layout_marginBottom="#dimen/small_margin"
>
<TextView
android:textColor="#android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="New words learnt:"
android:textStyle="bold"
android:layout_marginRight="#dimen/small_margin"/>
<TextView
android:textColor="#android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="259 words"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="#dimen/small_margin"
android:layout_marginLeft="#dimen/small_margin"
android:layout_marginBottom="#dimen/medium_margin"
>
<TextView
android:textColor="#android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="Word roots learnt:"
android:textStyle="bold"
android:layout_marginRight="#dimen/small_margin"/>
<TextView
android:textColor="#android:color/black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAppearance="?android:textAppearanceMedium"
android:text="37 words"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/button_layout_progress_fragment"
>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="200dp"
android:layout_width="match_parent"
android:id="#+id/gvBadges"
android:numColumns="3"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:gravity="center"
android:stretchMode="columnWidth"
>
</GridView>
</LinearLayout>
</LinearLayout>
</ScrollView>
I use a scrollview cover gridview inside. And I want to use ONLY scrollview to scroll down the screen, so gridview will show all item inside it.
How can I make that? Thank u in advance!
use
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
instead of
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:background="#android:color/transparent"
android:id="#+id/nested_scrollview">
Related
I am trying to implement Toolbar in Activity but when i try to run app after implementing Toolbar with
DrawerLayout >> CoordinatorLayout >> AppBarLayout
Content not showing. Here is layout file.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scrollbars="none"
android:background="#FFECECEC"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:background="#FFECECEC"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.05"
android:background="#drawable/header"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center|left"
android:text="Timer : "
android:textColor="#color/White"
android:textSize="12dp" />
<TextView
android:id="#+id/txtquesnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="1/10"
android:textColor="#color/White"
android:textSize="14dp" />
<ToggleButton
android:id="#+id/toggleButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#xml/togglecheck"
android:checked="false" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#drawable/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="4dp"
android:layout_weight="0.2"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/taque"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="3dp"
android:gravity="center|left"
android:text="Question"
android:textColor="#color/Black"
android:textSize="16dp"
android:typeface="normal" />
<com.applidium.shutterbug.FetchableImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="#drawable/splash_icon" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="0.3"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/taOpt5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_span="0"
android:gravity="center|left"
android:hint="Option 1"
android:padding="2dp"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/taOpt6"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 2"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center" >
<TextView
android:id="#+id/taOpt7"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 3"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center" >
<TextView
android:id="#+id/taOpt8"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 4"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
But when I move content inside AppBarLayout so everything is visible but inside appbar. how to fix this issue? Any idea.
While using Cordinator layout your layout should look like this
<CoordinatorLayout>
<AppBarLayout>
//Toolbar and other contents should come here
</AppBarLayout>
<Recycler Or Nested Scroll View>
<LinearLayout
app:layout_behavior="#string/appbar_scrolling_view_behavior">
//This is used when you have a collapsing toolbar and you need to add a scrolling behaviour for your views.
<LinearLayout/>
<Recycler Or Nested Scroll View/>
Instead try this layout.
<android.support.design.widget.CoordinatorLayout
android:background="#FFECECEC"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
</FrameLayout>
<LinearLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#drawable/header"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center|left"
android:text="Timer : "
android:textColor="#color/White"
android:textSize="12dp" />
<TextView
android:id="#+id/txtquesnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="1/10"
android:textColor="#color/White"
android:textSize="14dp" />
<ToggleButton
android:id="#+id/toggleButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#xml/togglecheck"
android:checked="false" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#drawable/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="4dp"
android:layout_weight="0.2"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/taque"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="3dp"
android:gravity="center|left"
android:text="Question"
android:textColor="#color/Black"
android:textSize="16dp"
android:typeface="normal" />
<com.applidium.shutterbug.FetchableImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="#drawable/splash_icon" />
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="0.3"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/taOpt5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_span="0"
android:gravity="center|left"
android:hint="Option 1"
android:padding="2dp"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center" >
<TextView
android:id="#+id/taOpt6"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 2"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center" >
<TextView
android:id="#+id/taOpt7"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 3"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center" >
<TextView
android:id="#+id/taOpt8"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 4"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
Your linear_layout height is fixed at 0 and hence not expandable. use wrap_content or match_parent.
Change
<LinearLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.05"
android:background="#drawable/header"
android:baselineAligned="false"
android:gravity="center" >
to
<LinearLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.05"
android:background="#drawable/header"
android:baselineAligned="false"
android:gravity="center" >
Just change the height android:layout_height="match_parent"
All code .
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFECECEC"
android:fitsSystemWindows="true"
android:scrollbars="none"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFECECEC">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"/>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:id="#+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.05"
android:background="#drawable/header"
android:baselineAligned="false"
android:gravity="center">
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center|left"
android:text="Timer : "
android:textColor="#color/White"
android:textSize="12dp"/>
<TextView
android:id="#+id/txtquesnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="1/10"
android:textColor="#color/White"
android:textSize="14dp"/>
<ToggleButton
android:id="#+id/toggleButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#xml/togglecheck"
android:checked="false"/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#drawable/seperator"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:layout_weight="0.2"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/taque"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="3dp"
android:gravity="center|left"
android:text="Question"
android:textColor="#color/Black"
android:textSize="16dp"
android:typeface="normal"/>
<com.applidium.shutterbug.FetchableImageView
android:id="#+id/imageView1"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="#drawable/splash_icon"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="0.3"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center">
<TextView
android:id="#+id/taOpt5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_span="0"
android:gravity="center|left"
android:hint="Option 1"
android:padding="2dp"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:baselineAligned="false"
android:gravity="center">
<TextView
android:id="#+id/taOpt6"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 2"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center">
<TextView
android:id="#+id/taOpt7"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 3"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="#drawable/normal"
android:gravity="center">
<TextView
android:id="#+id/taOpt8"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center|left"
android:hint="Option 4"
android:inputType="none"
android:padding="2dp"
android:shadowColor="#color/black"
android:singleLine="false"
android:textColor="#color/Black"
android:textSize="17dp"
android:typeface="serif"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>
Sometimes Coordinate Layout don't work with API version 25 or less if you are Using these for Application change it Other like Frame,Linear or Relative....
Layout also have Time Complexity i.e for Frame O(1), Linear (n), Relative O(n2)
I have a small question about linearlayouts.
Let's say i have, 1 horizontal linearlayout that contains 6 vertical linearlayouts.
I can make all linearslayouts the same width size if i use weightsum=12(of horizontal ll) and layout_weight=2(for vertical ll)
Result :
Now i want the "test1" layout to be 2 or 3 times smaller than the others.
I tried with weightsum=11, and layout_weigth=1(for the test1 layout) and layout_weight=2(for the others). I can't make it work, here is my code...
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="11">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#drawable/border"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test"
/>
</LinearLayout>
</LinearLayout>
How can i do it?
Thank you.
You need to use : android:layout_width="0dp" for the Linearlayout with the android:layout_weight="1" set as 1.
Now i want the "test1" layout to be 2 or 3 times smaller than the
others
You can reduce the layout weight attribute of test1. to 0.5..
use this layout:
<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:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="6">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test1" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/border"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="test" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Output
I have this layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/details" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:gravity="center"
android:weightSum="1"
android:visibility="visible">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Header text"
android:id="#+id/textView6"
android:background="#color/background"
android:textColor="#color/textColor"
android:padding="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/headerBackground"
android:padding="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView7"
android:textStyle="bold" />
</LinearLayout>
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listview_items"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|bottom">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:id="#+id/buttonBack"
android:layout_weight="1"
android:clickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/buttonNext"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
</RelativeLayout>
When the expandable listview has a long list of items, it expands over the bottom layout (the buttons layout).
Is there a way to tell the listview to expand up to where the bottom layout starts?
I have made some changes in your XML File.What I did is make your Button Layout android:layout_alignParentBottom="true" and make your details layout as android:layout_above="#+id/button_layout".Hope it will solve your issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button_layout"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:padding="8dp"
android:text="Header text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/textColor"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#color/headerBackground"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
</LinearLayout>
<ExpandableListView
android:id="#+id/listview_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="horizontal">
<Button
android:id="#+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Back"/>
<Button
android:id="#+id/buttonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Next"/>
</LinearLayout>
</RelativeLayout>
Hi I'm wondering about how exactly alertdialogs inflate custom xml layouts? In my example, the xml looks fine when I look at it in the eclipse editor however when the alertdialog builds it i looks completly different. (Sadly I do'nt have the reputation to post screenshots)
Heres the xml. The layout gets pushed up so to speak, so the bottom half of linearlayouts take up maybe 2 thirds of the page even though they have a weight of only 0.40 (ps if anyone could tell me an alternative to all these linearlayouts I would be gratefull!!)
Thank You
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.20"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.98"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingTop="32dp"
android:text="Share with..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#00C5CD" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.02"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#00C5CD" >
</View>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.40"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.50"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_prev"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/facebook" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Whatsapp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_preview3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/whatsapp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pillsas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Whatsapp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.40"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.50"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
<ImageView
android:id="#+id/iv_preview4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/email" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.150"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_customize_pill4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="10dp"
android:text="Email"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.350"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.50"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
Ok for what I understood all you need is like a header and under that a grid like layout right?? If I'm right TableLayout might be what you need.
Check this xml and see if it helps you
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:paddingLeft="20dp"
android:paddingTop="32dp"
android:text="Share with..."
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#00C5CD" />
<View
android:layout_width="wrap_content"
android:layout_height="1dp"
android:background="#00C5CD"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4">
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Some text"/>
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
I'm building an alertdialog to make a pre-payment summary. The problem is this alertdialog is taking all the screen instead of wrapping the content.
I've tried:
to turn the layout_height and layout_width of the first view of my layout to wrap_content
to use AlertDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE)
Activity code:
LayoutInflater inflater = BasketActivity.this.getLayoutInflater();
View layout = inflater.inflate(R.layout.dialog_pre_payment, null, false);
/* Set all TextView values here ....*/
Builder builder = new Builder(BasketActivity.this);
builder.setView(layout);
/* Avoid Double Pop-up */
if (payDialog != null && payDialog.isShowing()) {
payDialog.dismiss();
}
payDialog = builder.create();
payDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
payDialog.show();
dialog_pre_payment.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="10"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/basket"
style="#style/list_key"
android:textStyle="bold"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/border_grey"
android:layout_marginTop="5dp"
android:padding="15dp"
>
<ListView android:id="#+id/priced_basket"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
>
</ListView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:gravity="bottom"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="bottom">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Total:"
android:textStyle="bold"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/total_priced_list"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textStyle="bold"
android:gravity="right"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/beneficiary"
android:textStyle="bold"
android:layout_marginTop="20dp"
style="#style/list_key"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#drawable/border_grey"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:padding="15dp">
<ImageView android:id="#+id/customer_pic"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/user_pic"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="#+id/card_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
<TextView android:id="#+id/card_email"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:padding="15dp"
>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/amount"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/basket_total_price"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textColor="#color/neutral"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/previsional_balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance_after_payment"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:layout_gravity="right"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_height="40dp"
android:layout_width="match_parent"
android:weightSum="2"
android:gravity="center_horizontal">
<Button android:id="#+id/btn_cancel"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/cancel"
style="#style/CheckBalanceButton"
/>
<Button android:id="#+id/btn_validate"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/pay"
style="#style/PayButton"/>
</LinearLayout>
Al Blanc. Add a dummy Relativelayout around your actual code with height and width match_parent. I always used this technique.
Here is your modified code to give you an idea.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:background="#drawable/border_grey"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:weightSum="10"
android:paddingBottom="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/basket"
style="#style/list_key"
android:textStyle="bold"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/border_grey"
android:layout_marginTop="5dp"
android:padding="15dp"
>
<ListView android:id="#+id/priced_basket"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"
>
</ListView>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"
android:layout_marginTop="3dp"
android:layout_marginBottom="1dp"
android:gravity="bottom"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="bottom">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Total:"
android:textStyle="bold"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/total_priced_list"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textStyle="bold"
android:gravity="right"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="5"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/beneficiary"
android:textStyle="bold"
android:layout_marginTop="20dp"
style="#style/list_key"/>
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="#drawable/border_grey"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:padding="15dp">
<ImageView android:id="#+id/customer_pic"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/user_pic"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView android:id="#+id/card_name"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
<TextView android:id="#+id/card_email"
android:layout_height="wrap_content"
android:layout_width="match_parent"
style="#style/list_key"
android:textColor="#color/main_fg"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/border_grey"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:padding="15dp"
>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/amount"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/basket_total_price"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:textColor="#color/neutral"
android:textSize="16sp"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
android:background="#color/login_input_border"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/previsional_balance"
android:textColor="#color/main_fg"
android:textSize="16sp"/>
<TextView android:id="#+id/card_balance_after_payment"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="right"
android:layout_gravity="right"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_height="40dp"
android:layout_width="wrap_content"
android:weightSum="2"
android:gravity="center_horizontal">
<Button android:id="#+id/btn_cancel"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/cancel"
style="#style/CheckBalanceButton"
/>
<Button android:id="#+id/btn_validate"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:text="#string/pay"
style="#style/PayButton"/>
</LinearLayout>
</RelativeLayout>
Instead of calling the setView method on the AlertDialog.Builder instance, call the setView method on the AlertDialog instance. Like so:
payDialog = builder.create();
payDialog.setView(layout, 0, 0, 0, 0);
payDialog.show();
This should set the padding on the dialog to zero.