2017-10-31 21 views
1

Ich möchte background color #df0031 zu meinem RelativeLayout borders anzeigen, so dass mein ganzes Android screenbackground #df0031 einschließlich Grenzen haben wird, die gerade weiße Farbe haben.Wie füge ich RelativeLayout-Rahmen Hintergrundfarbe hinzu?

Android Screen

Bitte obigen Screenshot sehen und mir helfen, meine XML so zu aktualisieren, so dass die Grenzen des Android Screen die background color #df0031 Anpassung mit dem Rest des Bildschirms statt #ffffff haben.

Layout (XML):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="in.sitemakers.sitemakers.HomeFragment" 
android:background="@color/colorBgHome" 
> 

<TextView 
    android:id="@+id/home_heading" 
    android:layout_marginTop="10dp" 
    android:text="WE CREATE AWESOME WEB SITES" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textColor="@color/colorTextHome" 
    /> 
<TextView 
    android:layout_below="@+id/home_heading" 
    android:id="@+id/home_text" 
    android:layout_marginTop="28dp" 
    android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
    sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
    enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut 
    aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit 
    in voluptate velit esse cillum dolore eu fugiat nulla pariatur." 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:textColor="@color/colorTextHome" 
    /> 
    <ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:src="@drawable/main_device_image" 
    android:textColor="@color/colorTextHome" 
    /> 
</FrameLayout> 

Colors.xml

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <color name="colorPrimary">#3F51B5</color> 
    <color name="colorPrimaryDark">#303F9F</color> 
    <color name="colorAccent">#FF4081</color> 
    <color name="colorBgHome">#df0031</color> 
    <color name="colorTextHome">#ffffff</color> 
</resources> 

content_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="in.sitemakers.sitemakers.MainActivity" 
tools:showIn="@layout/app_bar_main"> 

<FrameLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

</RelativeLayout> 

Vielen Dank für Ihre Zeit.

+0

Hat das Layout, in dem diese Datei enthalten ist (HomeFragment), einen Rand um sie herum? –

+0

Bearbeiten Sie Ihre Frage fügen Sie etwas Code aus dem Layout der Aktivität, wo Sie das Fragment tatsächlich setzen – Xenolion

+0

Der Container des Fragments zeigen es – Xenolion

Antwort

1

Bearbeiten Sie Ihre content_main Datei, um die Auffüllung zu entfernen, die die weißen Ränder verursacht.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
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" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="in.sitemakers.sitemakers.MainActivity" 
tools:showIn="@layout/app_bar_main"> 

<FrameLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

</RelativeLayout> 
1

Im Container des Fragments haben Sie Polsterung. Löschen Sie es einfach.

+0

Eigentlich hatte der Fragesteller Padding keine Ränder. Gute Arbeit. Ich werde für zukünftige Benutzer bearbeiten! – Xenolion

+0

Ja, danke. Nur gemischt) –

0

diese Zeilen aus content_main.xml entfernen:

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
1

Sie haben padding zu entfernen! Löschen Sie diese Zeilen:

android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
+0

Ich bin froh, dass Sie das Problem @AmitGupta ** Happy Coding! ** gelöst haben. – Xenolion

Verwandte Themen