My scollview is not scrolling. I tried putting the scrollView inside a linear layout but still not working. I am trying the scroll view in landscape mode.Also bonus question, is there a layout that i can wrap my code into so that i can have my app be perfect on all screen sizes from small screen to big tablets.
<ScrollView 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="#drawable/bg"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:padding="10dp"
android:weightSum="2">
<LinearLayout
android:id="#+id/number"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/numbers1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NUMBERS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
tools:ignore="RtlCompat">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/family1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FAMILY"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/number"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/number"
android:background="#color/category_home"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
android:layout_toRightOf="#+id/number">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/colors1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout7"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout7"
android:layout_toRightOf="#+id/linearLayout7"
android:background="#color/category_home"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/nouns1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VERBS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_below="#+id/linearLayout7"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/linearLayout8"
android:layout_toStartOf="#+id/linearLayout8"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/verbs1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUNS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout9"
android:layout_toRightOf="#+id/linearLayout9"
android:background="#color/category_colors"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/phrases1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHRASES"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Try this as per your layout use HorizontalScrollView
<HorizontalScrollView 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="#color/colorPrimary"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="110dp"
android:padding="10dp"
android:weightSum="2">
<LinearLayout
android:id="#+id/number"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="0dp"
android:background="#color/cardview_shadow_end_color"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NUMBERS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
tools:ignore="RtlCompat">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FAMILY"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/number"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/number"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1"
android:layout_toRightOf="#+id/number">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="COLORS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout8"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout7"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout7"
android:layout_toRightOf="#+id/linearLayout7"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VERBS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout9"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_below="#+id/linearLayout7"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_toLeftOf="#+id/linearLayout8"
android:layout_toStartOf="#+id/linearLayout8"
android:background="#color/cardview_shadow_end_color"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NOUNS"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout10"
android:layout_width="150dp"
android:layout_height="130dp"
android:layout_alignBottom="#+id/linearLayout9"
android:layout_marginBottom="0dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toEndOf="#+id/linearLayout9"
android:layout_toRightOf="#+id/linearLayout9"
android:background="#color/colorRed"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kid" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHRASES"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</HorizontalScrollView>
Related
I have one fragment whose layout i want to show above keyboard when softkeyboard opens up. The layout is:
<?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:animateLayoutChanges="true"
android:background="#drawable/ic_bg_splash"
android:fitsSystemWindows="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/previous"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:background="#drawable/left"
android:padding="7dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="7dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="7dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="7dp"
android:orientation="vertical">
<ImageView
android:id="#+id/subCat"
android:layout_width="157.5dp"
android:layout_height="157.5dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="50dp"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="12dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:paddingLeft="20dp"
android:text="#string/enter_answer"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
<LinearLayout
android:layout_width="262.5dp"
android:layout_height="52.5dp"
android:layout_marginTop="7dp"
android:background="#drawable/answer_bg"
android:orientation="horizontal">
<EditText
android:id="#+id/answer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="8"
android:background="#null"
android:fontFamily="#font/nunito"
android:inputType="textNoSuggestions"
android:maxLines="1"
android:padding="7dp"
android:textColor="#android:color/white"
android:textSize="15sp" />
<ImageView
android:id="#+id/wrong_answer"
android:layout_width="27.5dp"
android:layout_height="28dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:src="#drawable/red_cross"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:layout_marginBottom="27dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito"
android:text="#string/reset"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="14.3sp" />
<TextView
android:id="#+id/submit_ans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:background="#drawable/white_rounded"
android:fontFamily="#font/nunito_semibold"
android:paddingLeft="17dp"
android:paddingTop="7dp"
android:paddingRight="17dp"
android:paddingBottom="7dp"
android:text="#string/submit"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="14.3sp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<ImageButton
android:id="#+id/next"
android:layout_width="37.5dp"
android:layout_height="37.5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="22dp"
android:background="#drawable/right" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/write_dark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:elevation="10dp"
android:visibility="gone">
<ImageView
android:id="#+id/write_success"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="10dp" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I have tried by setting windowssoftinputmode to adjustResize in manifest and also using fitsystemwindows to true in the fragment parent layout but still it is not working and using scrollview as parent layout instead of relativelayout. So please suggest me any workaround for this issue.
Edit: Added below activity.xml layout:
Below is the host activity layout:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/language_bg"
android:orientation="vertical"
tools:context=".home.HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bottom_rounded">
<RelativeLayout
android:id="#+id/taskBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_weight="1.7"
android:paddingLeft="30dp"
android:paddingTop="5dp">
<ImageView
android:layout_width="143dp"
android:layout_height="56dp"
android:layout_gravity="left|center_vertical"
android:src="#drawable/hello_logo" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/learn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:src="#drawable/learn_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/learn"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/learn_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor" />
</LinearLayout>
<LinearLayout
android:id="#+id/practice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:layout_width="42dp"
android:layout_height="28dp"
android:src="#drawable/practice_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/practice"
android:textColor="#color/lineColor"
android:textSize="11sp" />
<View
android:id="#+id/practice_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#color/lineColor"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:layout_marginRight="30dp"
android:layout_weight="1.3"
android:gravity="right"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/unlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="26.5dp"
android:layout_height="32dp"
android:src="#drawable/unlock_blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="#string/unlock"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:gravity="center_horizontal|bottom"
android:orientation="vertical">
<ImageView
android:layout_width="33dp"
android:layout_height="30dp"
android:layout_marginTop="2dp"
android:src="#drawable/language" />
<TextView
android:id="#+id/language_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:text="#string/lang"
android:textAllCaps="true"
android:textColor="#color/lineColor"
android:textSize="11dp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/appbar_practice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="12dp"
android:visibility="gone">
<LinearLayout
android:id="#+id/read_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="23.5dp"
android:layout_height="17.5dp"
android:background="#drawable/icon_read" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/read"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/read_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/speak_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="16.5dp"
android:layout_height="21.5dp"
android:background="#drawable/icon_speak" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/speak"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/speak_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/listen_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="18.5dp"
android:layout_height="18.5dp"
android:background="#drawable/icon_listen" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/listen"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/listen_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="#+id/write_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="17dp"
android:layout_height="19dp"
android:background="#drawable/icon_write" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="7dp"
android:fontFamily="#font/nunito_semibold"
android:text="#string/write"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="#+id/write_bar"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="12dp"
android:background="#android:color/white"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Try to put your scrollView into relative Layout.
After commenting this from my activity onCreate() it started working:
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
I'm trying to create a layout that has a 4 categories on the page, and in each one 2 spinners with a title. However at the moment my layout is all over the place when i run an emulator. How can i fix this? i feel like i'm not understanding the concept of the layout properly since everything i add becomes rigid to the layout and i can't easily move things.
layout
<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="match_parent"
android:orientation="vertical"
tools:context=".Page1Fragment">
<TextView
android:id="#+id/TextView0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginTop="25dp"
android:background="#A0DD0A"
android:text="TITLE" />
<LinearLayout
android:id="#+id/LinearLayoutTop"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/LinearLayoutTopSub"
android:layout_width="match_parent"
android:layout_height="134dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:id="#+id/TextView1"
android:layout_width="81dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="Weight" />
<Spinner
android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="25dp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/spinner"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="25dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutTopSub2"
android:layout_width="match_parent"
android:layout_height="134dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:id="#+id/TextView2"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="Computer" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="25dp" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/spinner2"
android:layout_marginLeft="0dp"
android:layout_marginTop="85dp"
android:layout_marginRight="30dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:background="#FFFFFF">
<LinearLayout
android:id="#+id/LinearLayoutTopSub3"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:id="#+id/TextView4"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="Distance" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="25dp" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="0dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutTopSub4"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:id="#+id/TextView5"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="Other" />
<Spinner
android:id="#+id/spinner6"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="25dp" />
<Spinner
android:id="#+id/spinner7"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="55dp"
android:layout_marginRight="0dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
I have added new linear and removed weight. try this one.
<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="match_parent"
android:orientation="vertical"
tools:context=".Page1Fragment">
<TextView
android:id="#+id/TextView0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginTop="25dp"
android:background="#A0DD0A"
android:text="TITLE" />
<!-- adding new linear -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/LinearLayoutTop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/LinearLayoutTopSub"
android:layout_width="wrap_content"
android:layout_height="134dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView1"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:text="Weight" />
<Spinner
android:id="#+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutTopSub3"
android:layout_width="wrap_content"
android:layout_height="134dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView3"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:text="Computer" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/spinner4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutBot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/LinearLayoutBotSub"
android:layout_width="wrap_content"
android:layout_height="134dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView4"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:text="Distance" />
<Spinner
android:id="#+id/spinner9"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/spinner7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayoutTopSub2"
android:layout_width="wrap_content"
android:layout_height="134dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/TextView2"
android:layout_width="150dp"
android:layout_height="20dp"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:text="Others" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My doubt is how to allign the imageview and textview spacing equally inside the relativelayout or anyother layout i tried but couldn't succeed in it let me post my code what i have tried so far:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swiperefresh"
tools:context=".Activities.VisitView"
android:background="#e3e3e3">
<RelativeLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="#+id/parent"
android:background="#e3e3e3"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:background="#fff"
android:layout_margin="20dp"
android:id="#+id/child"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:id="#+id/first"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_downloads"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Download"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:layout_below="#+id/e"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/first"
android:layout_marginLeft="10dp"
android:id="#+id/second">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e1"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upload"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e1"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/second"
android:id="#+id/third">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e3"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Print"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e3"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/third"
android:id="#+id/four">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e4"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notes"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e4"/>
</RelativeLayout>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/child"
android:layout_marginTop="5dp"
android:id="#+id/visit"
android:layout_marginBottom="5dp"
android:divider="#e3e3e3"
android:keepScreenOn="true"
android:scrollbars="vertical"
android:dividerHeight="0.5dp"
/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
But the textview and imageview not alligned inside the relative layout properly this is the image
How to allign this image and textview properly Thanks in advance!!
Try this,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e3e3e3">
<RelativeLayout
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e3e3e3"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#fff"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/first"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Download"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/second"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Upload"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/third"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e3"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Print"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/four"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e4"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Notes"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/visit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/child"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:divider="#e3e3e3"
android:dividerHeight="0.5dp"
android:keepScreenOn="true"
android:scrollbars="vertical" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swiperefresh"
android:background="#e3e3e3">
<RelativeLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="#+id/parent"
android:background="#e3e3e3"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:background="#fff"
android:layout_margin="20dp"
android:orientation="horizontal"
android:id="#+id/child"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/first"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e"
android:layout_centerHorizontal="true"
android:src="#drawable/inactive_settings"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Download"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:layout_below="#+id/e"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_toRightOf="#+id/first"
android:layout_marginLeft="10dp"
android:id="#+id/second">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e1"
android:layout_centerHorizontal="true"
android:src="#drawable/inactive_settings"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upload"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e1"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_toRightOf="#+id/second"
android:id="#+id/third">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e3"
android:layout_centerHorizontal="true"
android:src="#drawable/inactive_settings"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Print"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e3"/>
</RelativeLayout>
<RelativeLayout
android:layout_marginLeft="10dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_toRightOf="#+id/third"
android:id="#+id/four">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e4"
android:layout_centerHorizontal="true"
android:src="#drawable/inactive_settings"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notes"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e4"/>
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/child"
android:layout_marginTop="5dp"
android:id="#+id/visit"
android:layout_marginBottom="5dp"
android:divider="#e3e3e3"
android:keepScreenOn="true"
android:scrollbars="vertical"
android:dividerHeight="0.5dp"
/>
</RelativeLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e3e3e3"
tools:context=".Activities.VisitView">
<RelativeLayout
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e3e3e3"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/child"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:background="#fff"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_downloads" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Download"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/first"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Upload"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/second"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e3"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Print"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/four"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/third"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/e4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:src="#drawable/ic_up_arrow" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/e4"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="Notes"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/visit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/child"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:divider="#e3e3e3"
android:dividerHeight="0.5dp"
android:keepScreenOn="true"
android:scrollbars="vertical" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
Use LinearLayout with the weight sum:
<RelativeLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="#+id/parent"
android:background="#e3e3e3"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="#fff"
android:layout_margin="20dp"
android:id="#+id/child"
android:weightSum="4"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:id="#+id/first"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_downloads"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Download"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:layout_below="#+id/e"/>
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/first"
android:layout_marginLeft="10dp"
android:id="#+id/second">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e1"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upload"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e1"/>
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/second"
android:id="#+id/third">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e3"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Print"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e3"/>
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/third"
android:id="#+id/four">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:id="#+id/e4"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_up_arrow"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notes"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="10dp"
android:layout_below="#+id/e4"/>
</RelativeLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/child"
android:layout_marginTop="5dp"
android:id="#+id/visit"
android:layout_marginBottom="5dp"
android:divider="#e3e3e3"
android:keepScreenOn="true"
android:scrollbars="vertical"
android:dividerHeight="0.5dp"
/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
Please refer this, implement the linear layout inside the relative layout.Place your image view in place of my image view in Relative layout.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/relativeLayout2"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/tv"
android:id="#+id/starImage" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/music"
android:id="#+id/callImage" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/books"
android:id="#+id/shareImage" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/block_icon"
android:id="#+id/blockImage" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#drawable/edit"
android:id="#+id/deleteimage" />
</LinearLayout>
Your output will lokk like this.
I have this problem...
This is a screenshot of my XML File in Android Studio
this is the code...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/gris_300"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:scaleType="fitXY"
android:src="#drawable/image" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_below="#+id/imageView4"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_marginTop="-50dp">
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector_oval"
android:text="AGREGAR ITEMS"
android:textColor="#color/white"
android:layout_below="#+id/imageView4"
android:layout_centerHorizontal="true"
android:layout_above="#+id/linearLayout3"
android:padding="10dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" />
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#color/white"
android:clickable="false"
android:orientation="vertical"
android:layout_marginTop="-20dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ll_ver_pedido"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/carrito" />
<TextView
android:id="#+id/textView19"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu3"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_ver_estado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_estado" />
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu1"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_llamar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_llamar" />
<TextView
android:id="#+id/textView23"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu7"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_ver_mesa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_ver_mesa" />
<TextView
android:id="#+id/textView18"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu2"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pedido" />
<TextView
android:id="#+id/textView10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Ver mi ticket"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_pagar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView22"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu6"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView46"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Mis rewards"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_uber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView42"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView42"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Llamar a un taxi/uber"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView54"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Regalar una gift card"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
and this is a screnshot of my device...
I tried Framelayout...relative...
Help!
Thanks!
Final code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/gris_300"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:scaleType="fitXY"
android:src="#drawable/image" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_below="#+id/imageView4"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_marginTop="-30dp">
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#color/white"
android:clickable="false"
android:orientation="vertical"
android:layout_marginTop="20dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/ll_ver_pedido"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="50dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/carrito" />
<TextView
android:id="#+id/textView19"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu3"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_ver_estado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_estado" />
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu1"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_llamar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_llamar" />
<TextView
android:id="#+id/textView23"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu7"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_ver_mesa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_ver_mesa" />
<TextView
android:id="#+id/textView18"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu2"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pedido" />
<TextView
android:id="#+id/textView10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Ver mi ticket"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_pagar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView22"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="#string/text_menu6"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView46"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Mis rewards"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_uber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView42"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView42"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Llamar a un taxi/uber"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView44"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_pagar" />
<TextView
android:id="#+id/textView54"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Regalar una gift card"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/selector_oval"
android:text="AGREGAR ITEMS"
android:textColor="#color/white"
android:layout_below="#+id/imageView4"
android:layout_centerHorizontal="true"
android:layout_above="#+id/linearLayout3"
android:padding="10dp"
android:layout_gravity="center_horizontal" />
</FrameLayout>
I have a relative layout which contains two linear layouts. I want these two linear layouts to be placed in either halves of the relative layout containing them i.e. one to be positioned at top half and other at bottom half. Can anyone here help me with this. Here is the xml:
<RelativeLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_sn_icon"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_message_pic"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp"
/>
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#id/comments_list"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this..
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</LinearLayout>
</LinearLayout>
EDIT
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</RelativeLayout>
</LinearLayout>
// Try this way,hope this will help you to solve your problem...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:layout_gravity="right"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>