2016-07-24 7 views
12

मेरा टूलबारटूलबार में शीर्षक से पैडिंग को कैसे निकालें?

My toolbar

Google Play टूलबार

GooglePlay toolbar

मैं अनावश्यक गद्दी से हटा सकते हैं कैसे?

public void setUpToolbar(Toolbar toolbar, String title, @DrawableRes int resId) { 
    toolbar.setTitle(title); 
    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); 
    ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); 
    ab.setHomeAsUpIndicator(resId); 
    ab.setDisplayHomeAsUpEnabled(true); 
} 

मेरे एक्सएमएल में उपकरण पट्टी:

<android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 
+0

http://stackoverflow.com/a/38302389/1462770 – Amir

+4

ऐप: contentInsetStartWithNavigation = "0dp" – Amir

उत्तर

2

अपने कोड में इस प्रयास करें:

ActionBar actionBar = getSupportActionBar(); 
actionBar.setDisplayShowHomeEnabled(false); 
actionBar.setDisplayShowCustomEnabled(true); 
actionBar.setDisplayShowTitleEnabled(false); 
View customView = getLayoutInflater().inflate(R.layout.main_action_bar, null); 
actionBar.setCustomView(customView); 
Toolbar parent =(Toolbar) customView.getParent(); 
parent.setContentInsetsAbsolute(0,0); 
+0

नहीं, यह – gape

+0

@gape की मदद नहीं करता है अब इसे आज़माएं मुझे पता है –

7

बस जोड़ने

मेरे उपकरण पट्टी टुकड़ा टुकड़ा में मेरे कोड के अंदर है आपके टूलबार में

app:contentInsetLeft="0dp" 
app:contentInsetStart="0dp" 

यह ऐप जोड़ने में काम करना चाहिए

1

प्रयास करें: contentInsetLeft:

<android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:contentInsetLeft="0dp" 
      app:contentInsetStart="0dp" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 
9

उपयोग यह आपके उपकरण पट्टी एक्सएमएल टैग के अंदर

app:contentInsetStartWithNavigation="0dp" 
+0

यह वह है जो मेरे लिए काम करता है। धन्यवाद!! –

+0

सबसे स्वागत है :) –

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