简体   繁体   中英

How to get rid of extra space next to hamburger icon navigation drawer

在此处输入图片说明

I Have the layout shown as in this image and this is how my xml looks like :

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:contentInsetLeft="0dp"
    app:contentInsetStart="0dp"
    tools:context="pulsesecure.net.securewebbrowser.HomeActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:theme="@style/AppTheme.AppBarOverlay"
        >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:paddingTop="10dp"
            android:paddingBottom="5dp"
            app:popupTheme="@style/AppTheme.PopupOverlay">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <LinearLayout
                    android:id="@+id/frag_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="9"
                    android:orientation="horizontal"
                    android:visibility="gone">
                    <TextView
                        android:id="@+id/frag_title"
                        android:layout_width="0dp"
                        android:layout_weight="9"
                        android:layout_height="match_parent"
                        android:textColor="@android:color/white"
                        android:gravity="center_vertical"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        />

                    <ImageButton
                        android:id="@+id/add_tab_btn"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="match_parent"
                        android:src="@mipmap/ic_add_white_24dp"
                        android:background="@color/colorPrimaryDark"
                        />
                </LinearLayout>
                <LinearLayout
                    android:id="@+id/urlBar"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="9"
                    android:orientation="horizontal"
                    android:visibility="gone"
                    android:background="@color/colorPrimaryDark"
                    android:focusableInTouchMode="true"
                    >
                    <EditText
                        android:id="@+id/searchET"
                        android:layout_width="0dp"
                        android:layout_weight="9"
                        android:layout_height="match_parent"
                        android:textColor="@android:color/darker_gray"
                        android:layout_gravity="center"
                        android:imeOptions="actionGo"
                        android:singleLine="true"
                        android:hint="@string/hint_url"
                        android:selectAllOnFocus="true"
                        android:background="@drawable/rounded_edit_text"
                       />


                    <ImageButton
                        android:id="@+id/delete_url"
                        android:layout_width="0dp"
                        android:layout_weight="1"
                        android:layout_height="match_parent"
                        android:layout_margin="5dp"
                        android:src="@mipmap/ic_clear_white_24dp"
                        android:background="@color/colorPrimaryDark"
                        />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/select_url_bar"
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="9"
                    android:orientation="horizontal"
                    android:visibility="gone"
                    android:background="@color/colorPrimaryDark"
                    android:focusableInTouchMode="true"
                    >

                    <TextView
                        android:id="@+id/url_text"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginRight="5dp"
                        android:text="text view"
                        android:clickable="true"
                        android:singleLine="true"
                        android:gravity="center_vertical"
                        android:textColor="@android:color/black"
                        style="@style/PSFont"
                        android:background="@drawable/rounded_edit_text"/>


                </LinearLayout>

            </LinearLayout>

        </android.support.v7.widget.Toolbar>
        <ProgressBar
            android:id="@+id/page_load_progress"
            style="@android:style/Widget.ProgressBar.Horizontal"
            android:layout_width="match_parent"
            android:layout_height="3dp"
            android:progressTint="@color/colorAccent"
            android:visibility="invisible"
           />
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_home" />



</android.support.design.widget.CoordinatorLayout>

I need to get rid of the space between hamburger icon and the Edittext (highlighted with orange arrow). I tried padding and inset, but no luck so far. Can someone give me pointers on this ? Thank you.

My Bad , I should have searched harder : all I had to do was :

app:contentInsetStartWithNavigation="0dp" in my Toolbar layout.

Remove large padding after hamburger (menu) icon in Android Toolbar?

Try to add below attribute in your <android.support.v7.widget.Toolbar> .

app:contentInsetStartWithNavigation="0dp"

Adding this will work & if it is still not working then just add these two attributes as well

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM