2016-09-05 12 views
7

के बीच ऊंचाई समायोजित करें मैं वहाँ किसी भी तरह से शीर्षक पाठ और गूगल में तरह TabLayout के आइकन प्लस जहां माउस और पाठ शीर्षक कम से कम में कोई दूरी है के बीच की दूरी कम करने के लिए। मैंने खोज की है, लेकिन अब तक वैसे भी नहीं मिल सका।Tablayout शीर्षक पाठ और आइकन

enter image description here

संपादित

यह वह जगह है मैं कैसे आइकन और शीर्षक की स्थापना कर रहा हूँ:

tabLayout.getTabAt(3).setIcon(R.drawable.ic_more_horiz_white_24dp); 
tabLayout.getTabAt(3).setText("More"); 

और ये मेरे TabLayout है:

<android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:tabIndicatorColor="@color/white" 
     app:tabIndicatorHeight="2dp" 
     app:tabTextAppearance="?android:attr/textAppearanceSmall" 
     /> 
+0

आप अपने TabLayout के लिए किसी भी कस्टम लेआउट का उपयोग कर रहे हैं? – Nikhil

+1

क्या आपको इसका समाधान मिला? – Merian

+0

क्या आपको इसके लिए कोई समाधान मिला? –

उत्तर

2

TabLayout डेवलपर्स को सामग्री डिजाइन मानकों के अनुरूप बनाने में मदद करने के लिए पेश किया गया है। उस स्थिति में यह उचित टैब ऊंचाई है, आइकन और टेक्स्ट और आइकन और टेक्स्ट आकार के बीच पैडिंग। उनसे परिचित होने के लिए Material Design Guidelines देखें।

लेकिन अगर तुम सच में गद्दी पसंद नहीं है (और सामग्री डिज़ाइन दिशा निर्देशों के अनुसार आवेदन निर्माण करने के लिए नहीं करना चाहते हैं) आप इसे बदल सकते हैं।

आप @user13 answer उपयोग कर सकते हैं। इस तरह आप अपना लेआउट पास कर सकते हैं।

हालांकि याद रखें कि आप अधिक गतिशील TabLayout का निर्माण और यह TabLayout.Tab#setText(java.lang.CharSequence) है का उपयोग करें और TabLayout.Tab#setIcon(int) आप ऐसा लेआउट का उपयोग करना चाहिए करना चाहते हैं: पहचानकर्ता @android:id/icon और @android:id/text1 पर

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@android:id/icon"/> 
<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="0" 
    android:id="@android:id/text1" 
    android:gravity="center" 
    android:layout_below="@android:id/text1" /> 

looke। आप जोड़ देते हैं तो उन आईडी TabLayout है अपने लेआउट TabLayout वर्ग कोड के साथ काम करेंगे। अधिक जानकारी के लिए documentation पर एक नज़र डालें।

+0

निश्चित रूप से thnx, मुझे इसे आज़माएं। –

+0

आप "वजन" है, जो केवल LinearLayout माता-पिता में काम करता है का उपयोग करें और आप भी "layout_below" जो केवल RelativeLayout माता-पिता में काम करता है का उपयोग करें। मुझे लगता है कि इसे LinearLayout में लपेटा जाना चाहिए और "layout_below" संपत्ति को हटाया जा सकता है। – Singed

+0

धन्यवाद! आपके जवाब ने मेरी मदद की! +1 –

संबंधित मुद्दे