The title isn't good but i didn't know how else to describe
I have a relative layout with 2 elements, some container and a button at bottom.
I want the container fill all the space in the relativelayout leaving just the space enough to put the button
here is an example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout //i'm using linearlayout as an example, it could be anything here
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/b3"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="asdasdasdasdasdasdasdasd" />
</RelativeLayout>
here is how i want it look like
The red means the relavitive layout, the green the linear layout, and the yellow means the button...
how can i make it?
<?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"
android:background="#color/red"
android:padding="5dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/b"
android:background="#color/green">
</LinearLayout>
<Button
android:id="#+id/b"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="this is the button"
android:background="#color/yellow"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorAccent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="#+id/b3"
android:layout_margin="4dp"
android:background="#color/colorPrimary"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
<Button
android:id="#+id/b3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="asdasdasdasdasdasdasdasd" />
</RelativeLayout>
This should give you something close to what you want:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout //i'm using linearlayout as an example, it could be anything here
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="3"
android:gravity="center"
android:orientation="vertical">
</LinearLayout>
<Button
android:id="#+id/b3"
android:layout_width="wrap_content"
android:layout_height="0px"
android:layout_weight="1"
android:text="asdasdasdasdasdasdasdasd" />
</LinearLayout>
Related
I have created a layout. But at the bottom there is a white space left. I want the content of the relative layout at the extreme bottom of the screen. i.e seekbar and button at the bottom.
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<SeekBar
android:id="#+id/seekBar7"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button61"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_below="#id/seekBar7"
android:layout_centerInParent="true"
android:background="#drawable/play" />
</RelativeLayout>
</LinearLayout>
I want the white space at the bottom should be replaced with the content of relative layout.
I have uploaded the image
use this code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<SeekBar
android:id="#+id/seekBar7"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/button61"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_below="#id/seekBar7"
android:layout_centerInParent="true"
android:background="#drawable/play" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
instead of wrap_content You should put match_parent.
That would help it out. I hope you know about wrap_content and match_parent.If you don't look at this
https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html
I want to place a Relative layout below the custom Zoomview. I don't want the content of Relative Layout to get Zoom. I want a button to be placed at center of that relative layout.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="horizontal"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/twentyfive" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:text="#string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_centerInParent="true"
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
Never tested code, but hopefully it will work.
Try this -
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:orientation="vertical"
android:background="#drawable/images">
<com.example.acer.myapplication.ZoomView
android:id="#+id/iop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="#string/twentyfive" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerHorizontal="true"/> //Or use android:layout_centerInParent="true"
</RelativeLayout>
</LinearLayout>
Good morning guys,
I am having a bit of trouble resolving an issue and could use some help. I created an XML resource file called comment__layout. For some reason I cannot get the layout to display full screen. Please can you review the XML code and help. As you will see in the screenshot the Comment layout is loaded over the parent layout which is exactly what I want however, I would like the Comment layout to be full screen.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/comment__layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/dark_grey">
<LinearLayout
android:id="#+id/comment_heading__layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="Comments"
android:textSize="20sp"
android:textColor="#color/gps_orange"
android:textStyle="bold"/>
<Button
android:id="#+id/comment_close__button"
android:layout_width="40dp"
android:layout_height="40dp"
android:text="X"/>
</LinearLayout>
<LinearLayout
android:id="#+id/comments_add_comment__layout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/comment_add__edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/comment_add__button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+Add"/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/comments_text_views__scroll_layout"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/comments_text_views__layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</ScrollView>
</LinearLayout>
</LinearLayout>
PARENT XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/component_wizard_layout_parent__relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/component_wizard_layout_parent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/frame_component_wizard_manager"/>
<LinearLayout
android:id="#+id/component_wizard_component_popup__layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
I want to put button like above picture. But I have below image. I can't success this. Search a lot of but can't find it.
LinearLayout in LinearLayout has transparent background and there is button left of this.
Activity.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/genel_arkaplan"
android:orientation="vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="750dp"
android:layout_height="wrap_content"
android:paddingLeft="40dp"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/lay_transparan_aramasecenek"
android:layout_marginTop="100dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/lay_transparan_aramasecenek_beyaz">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:background="#drawable/kod_ile_arama"
android:id="#+id/imageButton" />
</LinearLayout>
</LinearLayout>
remove android:paddingLeft="40dp from LinearLayout Tag
Just remove below code from your "LinearLayout"
android:paddingLeft="40dp"
This is adding extra padding to your parent layout.
Below will be your final code.
<?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:background="#drawable/genel_arkaplan"
android:orientation="vertical" >
<LinearLayout
android:orientation="vertical"
android:layout_width="750dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/lay_transparan_aramasecenek"
android:layout_marginTop="100dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/lay_transparan_aramasecenek_beyaz">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:background="#drawable/kod_ile_arama"
android:id="#+id/imageButton" />
</LinearLayout>
</LinearLayout>
Try this code for batter result for your Button Icon. I Hope it is helpful for You.
<?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:background="#color/color_green"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/dimen_50"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/dimen_10"
android:layout_marginRight="#dimen/dimen_10"
android:layout_marginTop="100dp"
android:background="#android:color/holo_blue_light">
<Button
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#mipmap/ic_share"
android:scaleType="fitCenter" />
</RelativeLayout>
</LinearLayout>
I'm trying to use ExpandableListView with custom adapter in my project.
There is a result view of my activity with ExpandableListView:
How you can see, some rows doesn't have a right height and some lines are cropped.
What i do wrong?
There are my layout files
activity layout:
<?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">
<ExpandableListView
android:layout_width="matc_parent"
android:layout_height="match_parent"
android:id="#+id/noticeList"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/empty"
android:text="#string/empty"/>
</LinearLayout>
and layout for item of ExpandableListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/noticeImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="20dp"
android:id="#+id/noticeDate"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/noticeTitle"/>
</LinearLayout>
</LinearLayout>
Thanks all for answers.
The solution is use RelativeLayout instead LinearLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/noticeImage"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/noticeImage"
android:id="#+id/noticeDate"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/noticeTitle"
android:layout_toRightOf="#+id/noticeImage"
android:layout_below="#+id/noticeDate"
/>
</RelativeLayout>
Try to set layout_height for TextView noticeDate to wrap_content
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/noticeImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/noticeDate"/>
<TextView
android:layout_height="match_parent"
android:layout_width="fill_parent"
android:id="#+id/noticeTitle"/>
</LinearLayout>
</LinearLayout>