I use android:textIsSelectable="true" for TextView.
To enabled copy/select/paste For TextView it is OK
Issue
When I open this activity, it scrolls to middle automatically, like this Link
Why did this problem happen?
This is my layout code.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res/android" >
<data>
<variable
name="aboutMbti"
type="mbtitest.kiars.me.mbti.model.AboutMbti"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="2dp"
app:cardElevation="5dp" >
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbarSize="1dp"
android:scrollbarThumbVertical="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_splash_mtbi"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="3dp"
android:adjustViewBounds="true"
android:padding="5dp"
android:scaleType="centerCrop"
bind:imageUrl="#{aboutMbti.imageUrl}"/>
<TextView
android:id="#+id/txt_content_about_mtbi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/img_splash_mtbi"
android:layout_margin="5dp"
android:textIsSelectable="true"
android:padding="#dimen/title_padding"
android:text="#{aboutMbti.textContent}"
android:textColor="#color/ques_title"
android:textSize="15sp"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</layout>
Solution
You can add either android:focusableInTouchMode="true" or android:descendantFocusability="blocksDescendants" to the child layout in NestedScrollView
Try below code in your layout:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
...... >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true" >
...........
Finally, According to https://stackoverflow.com/users/6891563/khemraj comment, I Find
Mey solution ...
Just add android:focusableInTouchMode="true" to ImageView Like this :
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/apk/res/android" >
<data>
<variable
name="aboutMbti"
type="mbtitest.kiars.me.mbti.model.AboutMbti"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="2dp"
app:cardElevation="5dp" >
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbarSize="1dp"
android:scrollbarThumbVertical="#android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/img_splash_mtbi"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="3dp"
android:adjustViewBounds="true"
android:padding="5dp"
android:focusableInTouchMode="true"
android:scaleType="centerCrop"
bind:imageUrl="#{aboutMbti.imageUrl}"/>
<TextView
android:id="#+id/txt_content_about_mtbi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/img_splash_mtbi"
android:layout_margin="5dp"
android:textIsSelectable="true"
android:padding="#dimen/title_padding"
android:text="#{aboutMbti.textContent}"
android:textColor="#color/ques_title"
android:textSize="15sp"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</layout>
Tnx Guys
Related
I'm trying to create an app with Floating Action Button at top of my RecycleView on Fragment, can someone guide me how can i put my floating action button that will overlap my RecycleView without putting it on MainActivity?
i want to remove this part
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_weight="4"
android:layout_height="0dp"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</LinearLayout>
I am adding an example code (as same as your code with the expected result) using ConstraintLayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="vertical">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/floating_action_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_margin="16dp"
android:backgroundTint="#color/borderColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#drawable/ic_add"
app:tint="#FFFFFF" />
</androidx.constraintlayout.widget.ConstraintLayout>
Try like below:
<?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"
tools:context=".ui.filing.timelog.TimelogFilingFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/pullFilingTimelog"
android:layout_height="match_parent"
android:layout_width="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:overScrollMode="never"
android:id="#+id/rvFilingTimelog"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floating_action_button"
style="#style/Widget.Design.FloatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:backgroundTint="#color/borderColor"
android:layout_margin="16dp"
app:tint="#FFFFFF"
app:srcCompat="#drawable/ic_add"/>
</RelativeLayout>
Result:
Try this code
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#layout/app_toolbar"
android:layout_weight="0.6"
android:orientation="vertical"
android:stateListAnimator="#null">
<android.support.design.widget.FloatingActionButton
android:id="#+id/btn_asset_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:background="#android:color/transparent"
android:backgroundTint="#color/white"
android:src="#drawable/icon_camera"
app:rippleColor="#color/white" />
<android.support.v7.widget.RecyclerView
android:id="#+id/messages"
android:layout_width="match_parent"
android:layout_height="451dp"
android:layout_weight="1"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" />
I want to design xml page this type. I tried many of the code. Every time new problems are come. I need bottom navigation bar is fixed. In grid view ,i want android:numColums=3, android:verticalSpacing and android:horizontalSpacing Same(Look like instagram profile view grid images ).
XMl Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainSettingClass">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="175dp"
android:background="#dadada"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/com_facebook_button_background"/>
<TextView
android:id="#+id/amsc_txt_fbusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:layout_marginTop="2dp" />
</LinearLayout>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/grid_test"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:background="#FFFFFF"
android:stretchMode="columnWidth"
android:columnWidth="85dp"
android:numColumns="3"/>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#ffffff"
app:menu="#menu/bottom_navigation_gallery"/>
</FrameLayout>
As per your design you need scrollview for 2 above components and your BottomNavigationView is fix (not movable).
In your code you are not using scrollview first and second i'm not sure why you're using framelayout!
Here's my code which is exactly as per your given design try this if any concern you can ask! :)
Here's 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:orientation="vertical">
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_gallery">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/rel_titleHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#dadada"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#mipmap/ic_launcher" />
<TextView
android:id="#+id/amsc_txt_fbusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<GridView
android:id="#+id/grid_test"
android:layout_width="match_parent"
android:layout_height="400dp"
android:columnWidth="85dp"
android:horizontalSpacing="2dp"
android:numColumns="3"/>
</LinearLayout>
</ScrollView>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:layout_alignParentBottom="true" />
</RelativeLayout>
I'm learning Android Material from Slidenerd's video on Youtube. I got a problem when learn to make Recycler View on Drawer. But the position of Recycler View can't bottom of Image View. I want to throw that after the ImageView like another Material Design app. Let see the screenshot.
This is my code:
fragment_navigation_drawer.xml
<FrameLayout 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:background="#EEE"
tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment">
<LinearLayout
android:id="#+id/containerDrawerImage"
android:background="#F88C00"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- TODO: Update blank fragment layout -->
<ImageView
android:layout_width="280dp"
android:layout_height="140dp"
android:layout_marginBottom="18dp"
android:src="#drawable/bg_galungan"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</FrameLayout>
custom_row.xml
<?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="match_parent">
<ImageView
android:padding="8dp"
android:id="#+id/listIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_bookmark1"
android:layout_gravity="center_vertical"
/>
<TextView
android:id="#+id/listText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Doa Sehari-hari"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
Activity_main.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<include android:id="#+id/app_bar"
layout="#layout/app_bar" style="#style/AppTheme.Base" />
<TextView
android:layout_below="#+id/app_bar"
android:text="#string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<fragment
android:layout_width="#dimen/nav_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="#+id/fragment_navigation_drawer"
app:layout="#layout/fragment_navigation_drawer"
android:name="com.balinez.wdharmana.doahindu.NavigationDrawerFragment"
tools:layout="#layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Let's share if you also has same problem. Thanks for advance !
If it really not necessary to user FrameLayout as your parent, you can use RelativeLayout like I used.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EEE"
tools:context="com.balinez.wdharmana.doahindu.NavigationDrawerFragment">
<LinearLayout
android:id="#+id/containerDrawerImage"
android:background="#F88C00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- TODO: Update blank fragment layout -->
<ImageView
android:layout_width="280dp"
android:layout_height="140dp"
android:layout_marginBottom="18dp"
android:src="#drawable/beach"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/containerDrawerImage"
>
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
How could i achive next one after another layouts position (with height)?
Current code:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Новая заметка"/>
</RelativeLayout>
</RelativeLayout>
You can achieve the same layout when you will add "layout_above" property use this code.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:layout_above="#+id/relativeBottom"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeBottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:text="Новая заметка"/>
</RelativeLayout>
</RelativeLayout>
I would suggest this
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/myButton">
</ListView>
<Button
android:id="#+id/myButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="New Note"
android:layout_marginBottom="5dp"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Because I don't see the reason to put relative layout insid another relative layout.
In my understanding of what is needed, there's little need for relative layout at all. It can be achieved with just LinearLayout, which is less expensive.
<?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" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="#+id/myButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="New Note"
android:layout_marginBottom="5dp"
/>
</LinearLayout>
I have a linearlayout
and I want to create at the bottom of it a slice.
I know there are some options, but I'm a bit confused
1) android:layout_gravity:"bottom" --> this doesn't work for me for some reason.
2) android:gravity_weight="0" and give the sibling before it android:gravity_weight:"1"
3) android:height="wrap_content" and give the sibling before it android:height:"match_parent"
I know how to do this using relativeLayout, but I want to practice linearLayout
what would you suggest?
<?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/blue_bg"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/signup_illu_why" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=""
android:orientation="horizontal" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/signup_skip_icon" />
</LinearLayout>
Actually, you can set the parent element's gravity to bottom
<?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/blue_bg"
android:orientation="vertical"
android:gravity="bottom" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/signup_illu_why" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=""
android:orientation="horizontal" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/signup_skip_icon" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
... >
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<SomeViewThatNeedsGoBottom
... />
</LinearLayout>
try this
<?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="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</RelativeLayout>
<?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="#android:color/black"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.8" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.2" />
</LinearLayout>
surround your linear layout with framelayout and give gravity as bottom..
its simple than you think... many layouts are used just for easier move towards design
<FrameLayout
android:layout_height="fill_parent"
android:layout_width = "fill_parent">
<LinearLayout`
android:layout_height="wrap_content"
android:layout_width = "wrap_content"
android:layout_gravity = "bottom"
android:orientation = "vertical">
<Button
android:layout_height="wrap_content"
android:layout_width = "wrap_content"
android:text = "btn"/>
</LinearLayout>
</FrameLayout>
`
Use:
android:gravity="bottom"
example:
<LinearLayout
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some text"
android:layout_weight="2"
android:gravity="bottom" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some text"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some text"android:gravity="center"
android:layout_weight="2" />
</LinearLayout>
Put Relative in LinearLayout
and set Relative to matchparent, so you can use the layoutalignparentbottom
<?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/blue_bg"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/signup_illu_why" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=""
android:orientation="horizontal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/signup_skip_icon"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</LinearLayout>