Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add lines on tab bar icons
    primarykey
    data
    text
    <p>This is my tabbar example, and I want to add a layout as follows: lines on left, right, top and bottom of each icon like this image:</p> <p><a href="https://i.stack.imgur.com/bMaS5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bMaS5.png" alt="enter image description here"></a></p> <p>Currently my screen is like this:</p> <p><a href="https://i.stack.imgur.com/OKmYX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OKmYX.png" alt="enter image description here"></a></p> <p>My full code is below, how do I add lines on each icon?</p> <pre><code> public class TabSample extends TabActivity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setTabs() ; } private void setTabs() { addTab("payments", R.drawable.tab_home, ArrowsActivity.class); addTab("My Account", R.drawable.tab_home, ArrowsActivity.class); addTab("Spend Analyzer", R.drawable.tab_home, ArrowsActivity.class); addTab("Notification", R.drawable.tab_home, ArrowsActivity.class); addTab("Help", R.drawable.tab_home, ArrowsActivity.class); } private void addTab(String labelId, int drawableId, Class&lt;?&gt; c) { TabHost tabHost = getTabHost(); Intent intent = new Intent(this, c); TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false); TextView title = (TextView) tabIndicator.findViewById(R.id.title); title.setText(labelId); ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon); icon.setImageResource(drawableId); spec.setIndicator(tabIndicator); spec.setContent(intent); tabHost.addTab(spec); } } &lt;------------ main.xml--------------------------&gt; &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;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" /&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" /&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; &lt;------------------- tab_home.xml----------------------&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:drawable="@drawable/user" android:state_selected="true" /&gt; &lt;item android:drawable="@drawable/user_grey" /&gt; &lt;/selector&gt; &lt;----------- tab_indicator.xml-------------------&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="0dip" android:layout_height="40dip" android:layout_weight="1" android:orientation="vertical" android:padding="1dp"&gt; &lt;ImageView android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:src="@drawable/icon" /&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:textSize="8dp" style="?android:attr/tabWidgetStyle" /&gt; &lt;/RelativeLayout&gt; &lt;!----style.xml---------&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="app_theme" parent="android:Theme.NoTitleBar"&gt; &lt;/style&gt; &lt;/resources&gt; </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.
    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