android - Insert image as background set it bottom right corner inside Linear Layout -


i have activity based of vertical linearlayout

something that:

<?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:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent">      <fragment android:name="com.idatt.activities.titlebarfragment"         android:id="@+id/fr_title_bar"         android:layout_height="wrap_content"         android:layout_width="match_parent"         tools:layout="@layout/title_bar_fragment" />      <imageview         android:background="@drawable/img_logo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:layout_margintop="5dp"         android:contentdescription="company logo" />      <linearlayout         android:orientation="vertical"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:paddingleft="100dp"         android:paddingright="0dp"         android:paddingstart="100dp"         android:paddingend="0dp">          <textview style="@style/mytextviewlabel"             android:text="@string/str_under_logo" />          <textview android:id="@+id/tv_applicationversion"             style="@style/mytextviewlabel.black.data"             android:textcolor="@color/blue_end"             android:textstyle="bold"             android:text="version" />     </linearlayout>      <textview         style="@style/mytextviewlabel"         android:paddingtop="10dp"         android:text="ditat mobile dispatch designed asset-light motor carriers use independent contractors/owner operators power solution"         android:layout_gravity="center"         android:paddingbottom="20dp"         android:textsize="14sp"/>      <linearlayout         android:orientation="vertical"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:background="@color/blue_end"         android:padding="5dp">          <textview style="@style/mytextviewlabel"             android:layout_gravity="center_horizontal"             android:text="serial number"             android:textcolor="@color/white"/>          <textview android:id="@+id/tv_serial_number"             style="@style/mytextviewlabel"             android:layout_gravity="center_horizontal"             android:text="123456789012345"             android:textsize="22sp"             android:textcolor="#28cdfb"/>      </linearlayout>      <button         android:id="@+id/bt_opensourcelicenses"         android:text="open source licenses"         android:background="@color/transparent"         android:textcolor="@color/blue_end"         android:textstyle="bold"         android:textsize="20sp"         android:layout_margintop="10dp"         android:layout_width="match_parent"         android:layout_height="wrap_content" />  </linearlayout> 

i want place image background needs go right bottom corner. how do that?

edit:

i tried this, wrapping framelayout , setting gravity image doesn't put image bottom , still need know how align right

<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent">      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/img_background"         android:layout_gravity="bottom"/>      <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:orientation="vertical"         android:layout_width="fill_parent"         android:layout_height="fill_parent">          <fragment android:name="com.idatt.activities.titlebarfragment"             android:id="@+id/fr_title_bar"             android:layout_height="wrap_content"             android:layout_width="match_parent"             tools:layout="@layout/title_bar_fragment" />          <imageview             android:background="@drawable/img_logo"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:layout_margintop="5dp"             android:contentdescription="company logo" />          <linearlayout             android:orientation="vertical"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:paddingleft="100dp"             android:paddingright="0dp"             android:paddingstart="100dp"             android:paddingend="0dp">              <textview style="@style/mytextviewlabel"                 android:text="@string/str_under_logo" />              <textview android:id="@+id/tv_applicationversion"                 style="@style/mytextviewlabel.black.data"                 android:textcolor="@color/blue_end"                 android:textstyle="bold"                 android:text="version" />         </linearlayout>          <textview             style="@style/mytextviewlabel"             android:paddingtop="10dp"             android:text="ditat mobile dispatch designed asset-light motor carriers use independent contractors/owner operators power solution"             android:layout_gravity="center"             android:paddingbottom="20dp"             android:textsize="14sp"/>          <linearlayout             android:orientation="vertical"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:background="@color/blue_end"             android:padding="5dp">              <textview style="@style/mytextviewlabel"                 android:layout_gravity="center_horizontal"                 android:text="serial number"                 android:textcolor="@color/white"/>              <textview android:id="@+id/tv_serial_number"                 style="@style/mytextviewlabel"                 android:layout_gravity="center_horizontal"                 android:text="123456789012345"                 android:textsize="22sp"                 android:textcolor="#28cdfb"/>          </linearlayout>          <button             android:id="@+id/bt_opensourcelicenses"             android:text="open source licenses"             android:background="@color/transparent"             android:textcolor="@color/blue_end"             android:textstyle="bold"             android:textsize="20sp"             android:layout_margintop="10dp"             android:layout_width="match_parent"             android:layout_height="wrap_content" />       </linearlayout>  </framelayout> 

i suggest wrap relativelayout.

then in imageview tag add android:layout_alignparentbottom="true" , android:layout_alignparentright="true" align @ bottom right corner.

<?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">      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/img_background"         android:layout_alignparentbottom="true"         android:layout_alignparentright="true"/>      <linearlayout android:orientation="vertical"         android:layout_width="match_parent"         android:layout_height="match_parent">          <fragment android:name="com.idatt.activities.titlebarfragment"             android:id="@+id/fr_title_bar"             android:layout_height="wrap_content"             android:layout_width="match_parent"             tools:layout="@layout/title_bar_fragment" />          <imageview             android:background="@drawable/img_logo"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:layout_margintop="5dp"             android:contentdescription="company logo" />          <linearlayout             android:orientation="vertical"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:paddingleft="100dp"             android:paddingright="0dp"             android:paddingstart="100dp"             android:paddingend="0dp">              <textview style="@style/mytextviewlabel"                 android:text="@string/str_under_logo" />              <textview android:id="@+id/tv_applicationversion"                 style="@style/mytextviewlabel.black.data"                 android:textcolor="@color/blue_end"                 android:textstyle="bold"                 android:text="version" />         </linearlayout>          <textview             style="@style/mytextviewlabel"             android:paddingtop="10dp"             android:text="ditat mobile dispatch designed asset-light motor carriers use independent contractors/owner operators power solution"             android:layout_gravity="center"             android:paddingbottom="20dp"             android:textsize="14sp"/>          <linearlayout             android:orientation="vertical"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_gravity="center_horizontal"             android:background="@color/blue_end"             android:padding="5dp">              <textview style="@style/mytextviewlabel"                 android:layout_gravity="center_horizontal"                 android:text="serial number"                 android:textcolor="@color/white"/>              <textview android:id="@+id/tv_serial_number"                 style="@style/mytextviewlabel"                 android:layout_gravity="center_horizontal"                 android:text="123456789012345"                 android:textsize="22sp"                 android:textcolor="#28cdfb"/>          </linearlayout>          <button             android:id="@+id/bt_opensourcelicenses"             android:text="open source licenses"             android:background="@color/transparent"             android:textcolor="@color/blue_end"             android:textstyle="bold"             android:textsize="20sp"             android:layout_margintop="10dp"             android:layout_width="match_parent"             android:layout_height="wrap_content" />       </linearlayout>  </relativelayout> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -