How to set a layout in the middle of thescreen to show Image and text Android -


i have images url data, want show in detail view of app. ihave set liner layout, , imageview inside layout , text title. bit problem image showinf @ top of layout, not in cenrer of screen. how can set image in middle of layer , text below image. here xml code layout

    <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <imageview         android:id="@+id/detail_image"         android:layout_width="match_parent"         android:layout_height="wrap_content" android:adjustviewbounds="true"             android:scaletype="fitcenter" />          <textview             android:id="@+id/title"             android:layout_width="match_parent"             android:layout_height="50dp"             android:layout_alignparentbottom="true"             android:layout_alignparentend="true"             android:text="hallo world" />  </linearlayout> 

try use relativelayout insted of linearlayout and

make imageview android:layout_centerinparent="true"

make textview android:layout_below="@id/detail_image" below code

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/main_content"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">      <imageview         android:id="@+id/detail_image"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:adjustviewbounds="true"         android:layout_centerinparent="true"         android:scaletype="fitcenter" />      <textview         android:id="@+id/title"         android:layout_width="match_parent"         android:layout_height="50dp"         android:gravity="center"         android:layout_below="@id/detail_image"         android:text="hallo world" />  </relativelayout> 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -