Skip to content Skip to sidebar Skip to footer

Android: Layout On Top Of Tabs

As you can see, a linearlayout is on top of the tabs. What I want is to align the LinearLayout bottom to the tabs top. Alternatively aligning the RelativeLayout to the top of tabs

Solution 1:

<?xml version="1.0" encoding="UTF-8"?><RelativeLayoutandroid:id="@+id/RelativeLayout01"android:layout_width="fill_parent"android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"><LinearLayoutandroid:layout_width="fill_parent"android:orientation="vertical"android:id="@+id/LinearLayout02"android:layout_alignParentBottom="true"android:weightSum="1"android:layout_height="wrap_content"><LinearLayoutandroid:id="@+id/LinearLayout03"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_weight=".25"android:weightSum="1"android:orientation="vertical"><FrameLayoutandroid:id="@+id/FrameLayout02"android:layout_height="wrap_content"android:layout_width="fill_parent"android:paddingTop="20sp"android:paddingBottom="20sp"android:layout_weight=".5"><ImageButtonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/record"android:layout_gravity="center_horizontal"android:id="@+id/RecordImageButton"></ImageButton></FrameLayout><SeekBarandroid:id="@+id/SeekBar01"android:layout_height="wrap_content"android:layout_width="fill_parent"android:paddingBottom="5sp"android:paddingLeft="10sp"android:paddingRight="10sp"></SeekBar><FrameLayoutandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:id="@+id/FrameLayout03"><LinearLayoutandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:id="@+id/LinearLayout02"android:layout_gravity="center_horizontal"><ImageButtonandroid:layout_width="wrap_content"android:id="@+id/ImageButton01"android:layout_height="wrap_content"android:src="@drawable/play_rev"></ImageButton><ImageButtonandroid:layout_width="wrap_content"android:id="@+id/ImageButton02"android:layout_height="wrap_content"android:src="@drawable/play_stop"></ImageButton><ImageButtonandroid:layout_width="wrap_content"android:id="@+id/ImageButton03"android:layout_height="wrap_content"android:src="@drawable/play"></ImageButton></LinearLayout></FrameLayout></LinearLayout><LinearLayoutandroid:id="@+id/TabLayout"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_weight=".75"></LinearLayout></LinearLayout></RelativeLayout>

You can add your TabHost things into the TabLayout(last LinearLayout). Hope that will solve your problem.

Solution 2:

You can create params and rules :

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)

params.addRule(RelativeLayout.Top, anotherView.getId());

This line means that one view bottom will be top of another... This can works but it is adviced to do that in xml.

Post a Comment for "Android: Layout On Top Of Tabs"