I trying to add a LinearLayout under the listView but it has a space between ListView and the LinearLayout.How to remove it ? Thanks a lot.
<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"
tools:context=".MainActivity">
<ImageView
android:src="#drawable/expenses"
android:layout_marginTop="50dp"
android:layout_width="130dp"
android:layout_height="210dp"
android:id="#+id/imageView"
android:gravity="center"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="You haven't added any expenses yet"
android:textSize="15dp"
android:textColor="#color/btn_login"
android:gravity="center"
android:id="#+id/NoData"
android:layout_centerHorizontal="true"
android:layout_below="#+id/imageView"/>
<Button
android:layout_width="250dp"
android:layout_height="60dp"
android:text="Add Expenses"
android:id="#+id/button"
android:layout_centerHorizontal="true"
android:layout_below="#+id/NoData"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/listview"
android:footerDividersEnabled="false"
android:layout_weight="1"
android:layout_alignParentBottom="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="#color/light_gray"
android:orientation="horizontal"
android:id="#+id/linearLayout"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:layout_marginLeft="100dp"
android:id="#+id/Remaining"
android:paddingTop="10dp"
android:textSize="20sp"
android:layout_width="90dp"
android:layout_height="40dp"
android:text="Balance : " />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/balance"
android:paddingTop="10dp"
android:textSize="20sp"
android:layout_width="79dp"
android:layout_height="40dp"
android:text="balance " />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Below show my image
You need to remove this attribute android:paddingBottom="#dimen/activity_vertical_margin"
so it should look like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
paddingBottom will place a gap between your parent relative layout and the bottom of the screen
remove this attribute android:paddingBottom="#dimen/activity_vertical_margin"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:src="#drawable/expenses"
android:layout_marginTop="50dp"
android:layout_width="130dp"
android:layout_height="210dp"
android:id="#+id/imageView"
android:gravity="center"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="You haven't added any expenses yet"
android:textSize="15dp"
android:textColor="#color/btn_login"
android:gravity="center"
android:id="#+id/NoData"
android:layout_centerHorizontal="true"
android:layout_below="#+id/imageView"/>
<Button
android:layout_width="250dp"
android:layout_height="60dp"
android:text="Add Expenses"
android:id="#+id/button"
android:layout_centerHorizontal="true"
android:layout_below="#+id/NoData"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/listview"
android:footerDividersEnabled="false"
android:layout_weight="1"
android:layout_alignParentBottom="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:background="#color/light_gray"
android:orientation="horizontal"
android:id="#+id/linearLayout"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:layout_marginLeft="100dp"
android:id="#+id/Remaining"
android:paddingTop="10dp"
android:textSize="20sp"
android:layout_width="90dp"
android:layout_height="40dp"
android:text="Balance : " />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/balance"
android:paddingTop="10dp"
android:textSize="20sp"
android:layout_width="79dp"
android:layout_height="40dp"
android:text="balance " />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
The white space on the bottom is created at the very beginning of your code.
To get rid of it remove the following from your Relative Layout.
android:paddingBottom="#dimen/activity_vertical_margin"
Related
I am trying to arrange this layout so that the textview is positioned at the top of imageView7 but the app keeps crashing with error:
java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
Any help resolving this much appreciated
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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: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="com.mattblack.fibreapp.offers"
android:background="#000000">
<ImageView
android:layout_width="fill_parent"
android:layout_height="230dp"
android:id="#+id/imageView6"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/mainimage"
android:scaleType="fitXY" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_below="#+id/imageView6"
android:layout_centerHorizontal="true"
android:background="#000000"
android:id="#+id/frameLayout7">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Todays Offers"
android:id="#+id/textView9"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textSize="40sp" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#ffffff"
android:layout_gravity="bottom"
android:id="#+id/frameLayout8"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/home"
android:id="#+id/button13"
android:layout_gravity="left|center_vertical"
android:background="#ffffff"
android:onClick="goHome" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/code"
android:id="#+id/button14"
android:layout_gravity="right|center_vertical"
android:background="#ffffff"
android:onClick="goProfile" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OFFERS"
android:id="#+id/button15"
android:layout_gravity="center"
android:background="#ffffff"
android:onClick="showOffers" />
</FrameLayout>
<ListView
android:id="#+id/listViewOffers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/frameLayout8"
android:layout_below="#+id/frameLayout7"
android:background="#color/cardview_light_background"
android:scrollbars="none"
android:textAlignment="center"
android:visibility="visible" />
<FrameLayout
android:id="#+id/offerBoxView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.7"
android:background="#android:color/black">
</FrameLayout>
<ImageView
android:id="#+id/imageView7"
android:layout_width="336dp"
android:layout_height="365dp"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="visible"
app:srcCompat="#drawable/boxaffiliates" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_marginTop="#+id/imageView7"
/>
</FrameLayout>
</RelativeLayout>
You error is probably caused by this line :
android:layout_marginTop="#+id/imageView7"
In order to achieve the desired functionality you can use LinearLayout. Put your imageView7 and textView11 in a LinearLayout with vertical gravity.
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"/>
<ImageView
android:id="#+id/imageView7"
android:layout_width="336dp"
android:layout_height="365dp"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="visible"
app:srcCompat="#drawable/boxaffiliates" />
</LinearLayout>
Or RelativeLayout with using the attribute layout_below :
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"/>
<ImageView
android:id="#+id/imageView7"
android:layout_width="336dp"
android:layout_height="365dp"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="visible"
android:layout_below="#id/textView11"
app:srcCompat="#drawable/boxaffiliates" />
</RelativeLayout>
Your textview11 having wrong value of marginTop give that margin in dimensions you gave the id of other one
android:layout_marginTop="70dp"
like this
Im trying to create an adaptive layout containing a textview,listview and a button.Following is my code.
<?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:layout_margin="10dp">
<ListView
android:id="#+id/selectedComplianceList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:divider="#null"
android:dividerHeight="6dp"
android:clipToPadding="false"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_above="#+id/cont" />
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/cont"
android:orientation="vertical"
android:layout_marginTop="3dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<Button
android:id="#+id/submit_area"
style="#style/btn"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:text="Submit"
android:padding="5dp"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="ComplianceNames"
android:id="#+id/textView2"
android:layout_above="#+id/selectedComplianceList"
android:layout_centerHorizontal="true" />
</RelativeLayout>
The textview has to be at the top of the listview and button should be at the bottom.
Textview is not visible at the top. How can I make it visible
Even though I have used divided height property, the listview items are not equally spaced enough. Moreover,if im setting the divider, the size of divider is high. How can I make it thin?
if you use LinearLayout(Vertical) its better option because you want three controls in vertical lines.
so try to do below code its very easy to understand and implements.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="ComplianceNames"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="center" />
<ListView
android:id="#+id/selectedComplianceList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_above="#+id/cont"
android:layout_below="#+id/textView2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:clipToPadding="false"
android:divider="#null"
android:dividerHeight="2dp"
android:layout_weight="1" />
<Button
android:id="#+id/submit_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:text="Submit" />
</LinearLayout>
Use android:layout_alignParentTop="true" in TextView , android:layout_alignParentBottom="true" in LinearLayout and
android:layout_above="#+id/cont"
android:layout_below="#+id/textView2" in ListView
<?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:layout_margin="10dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="ComplianceNames"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/selectedComplianceList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_above="#+id/cont"
android:layout_below="#+id/textView2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:clipToPadding="false"
android:divider="#null"
android:dividerHeight="6dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<LinearLayout
android:id="#+id/cont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:orientation="vertical" >
<Button
android:id="#+id/submit_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:text="Submit" />
</LinearLayout>
</RelativeLayout>
Try This
<?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:layout_margin="10dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="ComplianceNames"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/selectedComplianceList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:layout_above="#+id/submit_area"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:clipToPadding="false"
android:divider="#null"
android:dividerHeight="6dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" />
<Button
android:id="#+id/submit_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_margin="2dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:padding="5dp"
android:text="Submit" />
<?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:layout_margin="10dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="ComplianceNames"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/selectedComplianceList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_above="#+id/cont"
android:layout_below="#+id/textView2"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:clipToPadding="false"
android:divider="#null"
android:dividerHeight="2dp"/>
<LinearLayout
android:id="#+id/cont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:orientation="vertical" >
<Button
android:id="#+id/submit_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:padding="5dp"
android:text="Submit" />
</LinearLayout>
</RelativeLayout>
I have 4 linear layout inside the relative layout and a button. I am able to see only first 3 relative layout and button in horizontal view. The fourth linearlayout is not seen but it is seen in the vertical view. Please help.
<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="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal"
android:id="#+id/linearLayout1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="top">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gen"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/gen"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:layout_below="#+id/linearLayout1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView2"
android:src="#drawable/year"/>
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:layout_below="#+id/linearLayout2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView3"
android:src="#drawable/im"/>
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF"
android:id="#+id/linearLayout4"
android:layout_below="#+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="53dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView4"
android:src="#drawable/rt2"/>
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="58dp"
android:id="#+id/filterbutton"
android:text="filter"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:textStyle="bold"/>
</RelativeLayout>
You need to keep entire child linear layout inside scrollview so that it will be scrollable & visible.Check below updated xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/filterbutton"
android:layout_alignParentTop="true"
android:fadingEdge="none"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/gen" />
<TextView
android:id="#+id/gen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/year" />
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/im" />
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/rt2" />
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/filterbutton"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:text="filter"
android:textStyle="bold" />
</RelativeLayout>
Add an ScrollingView as the parent,and inside that the RelativeLayuot and it add an scrollbar to see all.
You can see more info in android developers ScrollingView
Try out this solution,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:fadingEdge="none"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<LinearLayout
android:id="#+id/linearLayoutWhole"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/gen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout1"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/movieyear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Year"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/imdb_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search"
android:textSize="25sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginTop="53dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cal" />
<TextView
android:id="#+id/rotten_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text=" Search By Rating"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/filterbutton"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_alignParentBottom="true"
android:background="#ffff9a88"
android:text="filter"
android:textStyle="bold" />
</RelativeLayout>
I am using listiview for my application,in my listiview i set something like this
listitem1(Image)
listitem2(Image+Image)
Now issue is in my second row i want to get space between two images,but it is not working,following is my xml layout and screen shot of my output
listview_view
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F3"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/lnrsearchviews"
android:layout_below="#+id/imgshead"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/rect_search"
>
<!--<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/searchs"
android:layout_gravity="center_vertical"
/>-->
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/autosearchbyname"
android:hint="Search"
/>
</LinearLayout>
<!-- <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/txt_shopbydept"
android:text="Shop By Departments"
android:textSize="20dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_below="#+id/lnrsearchviews"
/>-->
<ListView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/list_menu"
android:layout_below="#+id/lnrsearchviews"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="20dp"
android:dividerHeight="8dp"
android:divider="#f3f3f3"
></ListView>
</RelativeLayout>
list_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="150dp"
android:layout_height="match_parent"
android:id="#+id/btntest"
android:background="#drawable/ab"
android:orientation="horizontal"
>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="180dp"
android:id="#+id/id"
android:background="#drawable/heads"
android:layout_weight="1.17">
<RelativeLayout
android:layout_height="40dp"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:padding="2dp"
android:text="abd"
android:id="#+id/txt_allproductsname"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:padding="2dp"
android:text="abddd"
android:id="#+id/txt_allproductsquty"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Mygetview
http://pastie.org/10289187#5
Try this as your list_item and use set visibility of the second ImageView to gone when you need to show only one image.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="#+id/first_imageview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="#9ff0"
android:src="#drawable/ic_launcher" />
<ImageView
android:id="#+id/second_imageview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#9ff0"
android:src="#drawable/ic_launcher" />
</LinearLayout>
I am making a layout for my application and I encounter the following problem.
In my layout file
But when I put it in my Fragment (via a ListView, or just with , it looks like this:
category.xml (template to populate ListView afterwards)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/second_grey">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:id="#+id/categoryName"
android:text="#string/sport"
android:textSize="24sp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="12dp"
android:id="#+id/button"
android:text="#string/see_more"
android:textSize="12sp"
android:background="#drawable/blue"
android:textColor="#android:color/white" />
</RelativeLayout>
<LinearLayout
android:orientation="horizontal"
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="0.99">
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img1"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/football"
android:padding="8dp"
android:id="#+id/tv1"
android:layout_below="#+id/imgContainer1"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer2">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img2"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/basketball"
android:padding="8dp"
android:id="#+id/tv2"
android:layout_below="#+id/imgContainer2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:background="#drawable/card"
android:layout_width="0dp"
android:layout_weight="0.33">
<com.favega.groups.SquareLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/imgContainer3">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:id="#+id/img3"
android:src="#drawable/img_football" />
</com.favega.groups.SquareLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tennis"
android:padding="8dp"
android:id="#+id/tv3"
android:layout_below="#+id/imgContainer3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</LinearLayout>
fragment_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:background="#color/second_grey"
tools:context="com.favega.groups.MainActivity$CategoryFragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/category"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"></include>
Try this.. Use TextView instead of Button if you use Button defaultly it'll take much of size
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="12dp"
android:id="#+id/button"
android:text="see_more"
android:textSize="12sp"
android:background="#drawable/blue"
android:textColor="#android:color/white" />
Remove padding from relative layout of fragment_main.xml