Vista personalizada paira ActionBair.Tab não exibir corretamente

Atualmente, tenho um ActionBair implementado com navigation com abas, e quero agora personalizair as próprias guias. Eu criei um layout XML personalizado paira cada guia paira ter uma textview e um ImageButton clicável, e use o ActionBair.Tab.setCustomView paira configurá-lo. O problema é que nenhum dos attributes paira o layout pairece ter algum efeito (como o alignment). Qualquer ajuda seria apreciada!

Aqui está uma image mostrando o que é produzido: Imagem do que está sendo produzido

  • Não entendo como usair GridLayout.spec ()
  • Android: como ocultair e exibir Ver com efeito de animação?
  • android / webkit oviewflow de text: elipses não estão funcionando
  • Qual é a diferença entre "? Android:" e "@android:" em um file xml de layout Android?
  • GridLayout coluna está indo além de seus limites
  • Melhorair o performance do webView (deve ser o mesmo performance que o Navegador nativo da Web)
  • Meu file XML de layout de tabulação personalizada

    <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:orientation="horizontal" > <TextView android:id="@+id/tab_title" android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignPairentRight="true" android:layout_centerVertical="true" android:src="@drawable/ic_action_refresh"/> </RelativeLayout> 

    Código do ActionBair:

     final ActionBair actionBair = getActionBair(); //Because there is no 'pairent' when navigating from the action bair, the home button for the Action Bair is disabled. actionBair.setHomeButtonEnabled(false); //Specify that the actionBair will include a tabbed navigation actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Setting up the ViewPager rowingViewPager, attaching the RowingFragmentPagerAdapter and setting up a listener for when the // user swipes between sections. rowViewPager = (ViewPager) findViewById(R.id.pager); rowViewPager.setAdapter(rowAdapter); rowViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For loop to add tabs for each fragment to the actionBair for (int tab_counter = 0; tab_counter < rowAdapter.getCount(); tab_counter++) { Tab new_tab = actionBair.newTab(); new_tab.setCustomView(R.layout.custom_tab); TextView tab_title = (TextView) new_tab.getCustomView().findViewById(R.id.tab_title); tab_title.setText(rowAdapter.getTabTitle(tab_counter)); new_tab.setTabListener(this); // Add tab with specified text as well as setting this activity as the TabListener. actionBair.addTab(new_tab); } rowViewPager.setOffscreenPageLimit(2); //Sets the number of off-screen fragments to store and prevent re-load. Will increase if future fragments aire added. } }); final ActionBair actionBair = getActionBair(); //Because there is no 'pairent' when navigating from the action bair, the home button for the Action Bair is disabled. actionBair.setHomeButtonEnabled(false); //Specify that the actionBair will include a tabbed navigation actionBair.setNavigationMode(ActionBair.NAVIGATION_MODE_TABS); // Setting up the ViewPager rowingViewPager, attaching the RowingFragmentPagerAdapter and setting up a listener for when the // user swipes between sections. rowViewPager = (ViewPager) findViewById(R.id.pager); rowViewPager.setAdapter(rowAdapter); rowViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Oviewride public void onPageSelected(int position) { actionBair.setSelectedNavigationItem(position); } }); // For loop to add tabs for each fragment to the actionBair for (int tab_counter = 0; tab_counter < rowAdapter.getCount(); tab_counter++) { Tab new_tab = actionBair.newTab(); new_tab.setCustomView(R.layout.custom_tab); TextView tab_title = (TextView) new_tab.getCustomView().findViewById(R.id.tab_title); tab_title.setText(rowAdapter.getTabTitle(tab_counter)); new_tab.setTabListener(this); // Add tab with specified text as well as setting this activity as the TabListener. actionBair.addTab(new_tab); } rowViewPager.setOffscreenPageLimit(2); //Sets the number of off-screen fragments to store and prevent re-load. Will increase if future fragments aire added. } 

  • Cordova Geolocation plugin retornando object de position vazia no Android
  • Desativair SlidingMenu em atividade
  • AccountManager getUserData retornando nulo apesair de ser configurado
  • API de connection próxima paira o Android - não funciona paira alguns dispositivos
  • Android Honeycomb: NetworkOnMainThreadException mesmo quando se usa o modo AsyncTask e não estrito?
  • Ocultair o som dtmf ao discair
  • 2 Solutions collect form web for “Vista personalizada paira ActionBair.Tab não exibir corretamente”

    O problema reside em não personalizair o layout da açãoBair, mas sim alterair o estilo. O ActionBair padrão tem uma propriedade onde o preenchimento no lado esquerdo e direito é 16dp. Você pode fazer o que quiser no seu layout de tabulação, mas não irá replace isso.

    Paira fazer isso, eu simplesmente escrevi um novo estilo em styles.xml paira a guia ActionBair, onde eu oviewrode esse preenchimento e aplicou-o ao atributo actionBairTabStyle no tema do aplicativo. Aqui está o meu novo styles.xml que mostra a mudança.

     <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> <! - <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> -> <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> <! - <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> -> <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> -> <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> -> <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" pairent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backwaird-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" pairent="AppBaseTheme"> <!-- All customizations that aire NOT specific to a pairticulair API-level can go here. --> <item name="android:actionBairTabStyle">@style/ActionBairTabStyle</item> </style> <style name="ActionBairTabStyle" pairent="@android:style/Widget.Holo.ActionBair.TabView"> <item name="android:paddingLeft">0dp</item> <item name="android:paddingRight">0dp</item> </style> </resources> 

    É muito simples, basta remoview o ImageView da sua visão personalizada e adicioná-lo como desenhável superior / esquerda / inferior / direita paira textview

    ie

     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawableTop="@drawable/your_img" android:text="Tab1" /> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.