Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Layout on top of tabs
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/HJFTu.jpg" alt="alt text"></p> <p>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.</p> <p>Alternatively aligning the RelativeLayout to the top of tabs may also work.</p> <p>Here's the corresponding code for the view above:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="wrap_content" android:id="@+id/LinearLayout02" android:layout_alignParentBottom="true"&gt; &lt;FrameLayout android:id="@+id/FrameLayout02" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingTop="20sp" android:paddingBottom="20sp"&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/record" android:layout_gravity="center_horizontal" android:id="@+id/RecordImageButton"&gt;&lt;/ImageButton&gt; &lt;/FrameLayout&gt; &lt;SeekBar android:id="@+id/SeekBar01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:paddingBottom="5sp" android:paddingLeft="10sp" android:paddingRight="10sp"&gt;&lt;/SeekBar&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/FrameLayout03"&gt; &lt;LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/LinearLayout02" android:layout_gravity="center_horizontal"&gt; &lt;ImageButton android:layout_width="wrap_content" android:id="@+id/ImageButton01" android:layout_height="wrap_content" android:src="@drawable/play_rev"&gt;&lt;/ImageButton&gt; &lt;ImageButton android:layout_width="wrap_content" android:id="@+id/ImageButton02" android:layout_height="wrap_content" android:src="@drawable/play_stop"&gt;&lt;/ImageButton&gt; &lt;ImageButton android:layout_width="wrap_content" android:id="@+id/ImageButton03" android:layout_height="wrap_content" android:src="@drawable/play"&gt;&lt;/ImageButton&gt; &lt;/LinearLayout&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Here is the code for the tabs:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TabWidget android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@android:id/tabs" android:layout_alignParentBottom="true" /&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@android:id/tabcontent" /&gt; &lt;/RelativeLayout&gt; &lt;/TabHost&gt; </code></pre> <p>MainActivity, which sets an activity for each tab:</p> <pre><code>public void initTabs() { Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab intent = new Intent().setClass(this, FirstActivity.class); spec = tabHost.newTabSpec("tab1").setIndicator("Tab", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, SecondActivity.class); spec = tabHost.newTabSpec("tab2").setIndicator("Tab 2", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); intent = new Intent().setClass(this, ThridActivity.class); spec = tabHost.newTabSpec("tab3").setIndicator("Tab 3", res.getDrawable(R.drawable.ic_tab_artists)) .setContent(intent); tabHost.addTab(spec); tabHost.setCurrentTab(0); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload