Reputation: 113
I want to make header placed adjacent to its background. I need to make the view compatible to all the screens without using fixed pixel value.
Help me to Solve this issue.
Upvotes: 0
Views: 402
Reputation: 2289
You can divide your screen in two parts by giving weight. How..?
This is the xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="6">
<LinearLayout
android:id="@+id/headerlayout"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="fill_parent"
android:background="#ffff00"></LinearLayout>
<LinearLayout
android:id="@+id/baselayout"
android:layout_weight="5"
android:layout_height="0dp"
android:layout_width="fill_parent"
android:background="@android:color/darker_gray"></LinearLayout>
</LinearLayout>
There you will notice one layout which is of yellow color can act as header in your code. It will act same for all device. you can increase and decrease the weight of layout as your requirment, as how the header you want.
Upvotes: 1