jeudi 20 août 2015

Toolbar has margin on left that i can't remove. (short sample xml included)



I have placed a toolbar into an activity and set its width to match parent and its margin and padding to 0dp. I then placed a relative layout inside and did the same width to match parent and its margin and padding to 0dp. The relative layout (i set it background to grey) has what looks like a 10p margin on its left I can not remove. This happens if you replace the relative layout with anything such as text or a button.

Any help would be appreciated. (xml layout code and below)

(I can not post a pic because I am new to the forums but there is a green toolbar that takes up the full width of the device and a grey relative layout inside which touches the right side of the screen but the left has an approximately 10dp gap to the edge of the toolbar)

(I replaced http with BADGER in the code below as I can not post links)

mydemo.xml

PHP Code:







<RelativeLayout xmlns:android="BADGER://schemas.android.com/apk/res/android"
    
xmlns:tools="BADGER://schemas.android.com/tools"
    
android:layout_width="match_parent"
    
android:layout_height="match_parent"
    
tools:context=".Loadscreen_Activity">

    <
android.support.v7.widget.Toolbar xmlns:android="BADGER://schemas.android.com/apk/res/android"
        
android:id="@+id/mytoolbar"
        
android:layout_width="match_parent"
        
android:layout_height="wrap_content"
        
android:background="@color/ColorPrimary"
        
android:layout_margin="0dp"
        
android:padding="0dp" >

        <
RelativeLayout
            android
:layout_width="match_parent"
            
android:layout_height="30dp"
            
android:background="#CCC"
            
android:layout_margin="0dp"
            
android:padding="0dp" >
        </
RelativeLayout>

    </
android.support.v7.widget.Toolbar>

</
RelativeLayout









styles.xml

PHP Code:







<resources>

    <!-- 
Base application theme. -->
    <
style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- 
Customize your theme here. -->
        <
item name="colorPrimary">@color/ColorPrimary</item>
        <
item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
    </
style>

</
resources












Aucun commentaire:

Enregistrer un commentaire