Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1)- Create a layout file with name report_tabs.xml or any name you like.</p> <p>In report_tabs use this code.</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout_tabsLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/btn_selector" android:gravity="center" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/img_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="3dp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>2)- And use below code in your activity.</p> <pre><code> Intent intent; tabhost = getTabHost(); TabHost.TabSpec tabspec; intent = new Intent().setClass(getApplicationContext(),xxxxx.class); tabspec = tabhost.newTabSpec("First"); view = LayoutInflater.from(this).inflate(R.layout.report_tabs, tabhost.getTabWidget(), false); imgtabF = (ImageView) view.findViewById(R.id.img_icon); imgtabF.setBackgroundResource(R.drawable.tab_icon_selector); tabspec.setIndicator(view); tabspec.setContent(intent); tabhost.addTab(tabspec); </code></pre> <p>3)- Create a file with name tab_icon_selector in drawable for changing the icon on tab click like this:-</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;!-- Non focused states --&gt; &lt;item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/medical_icon_unselect" /&gt; &lt;item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/medical_icon_sel" /&gt; &lt;!-- Focused states --&gt; &lt;item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/medical_icon_sel" /&gt; &lt;item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/medical_icon_sel" /&gt; &lt;!-- Pressed --&gt; &lt;item android:state_pressed="true" android:drawable="@android:color/transparent"/&gt; &lt;/selector&gt; </code></pre> <p>Now you can create your custom Tab bar and your image icon will be in center of the tab.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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