User 1278
User 1278

Reputation: 177

How to change background of complete layout

There is a list view in my android app.I give black colour to list. I want to make the background of layout grey colour. But I cannot make the complete background grey ,only part up to to which list extended becomes grey,rest of part remains white. How can I make remaining part also grey. Here is xml code for layout of listview.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_color_grey_500"
android:orientation="vertical" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="97dp" >

    <ImageView
        android:id="@+id/expandable_lv_social_background_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/cd_main_image"
        android:scaleType="centerCrop"
        android:src="@drawable/expandable_social_background_image" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical" >

        <ImageView
            android:id="@+id/expandable_lv_social_image"
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_marginBottom="16dp"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="24dp"
            android:layout_marginTop="16dp" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="4dp"
            android:gravity="center_vertical"
            android:orientation="vertical" >

            <sampleapp.kodspider.com.sampleapp.font.RobotoTextView
                android:id="@+id/expandable_lv_social_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="6dp"
                android:text="Sample App"
                android:textColor="@android:color/white"
                android:textSize="16sp"
                app:typeface="robotoLight" />

            <sampleapp.kodspider.com.sampleapp.font.RobotoTextView
                android:id="@+id/expandable_lv_social_place"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Stage Shows"
                android:textColor="@android:color/white"
                android:textSize="12sp"
                app:typeface="robotoLight" />
         </LinearLayout>
       </LinearLayout>
      </RelativeLayout>

    <View
    android:id="@+id/divider_top"
    android:layout_width="match_parent"
    android:layout_height="3dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView1"
    android:background="@color/material_light_yellow_600" />

    <sampleapp.kodspider.com.sampleapp.view.AnimatedExpandableListView
    android:id="@+id/expandable_lv_social_list_view"
    android:background="@drawable/com_facebook_tooltip_black_background"

    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    </sampleapp.kodspider.com.sampleapp.view.AnimatedExpandableListView>



</LinearLayout>

here is my screen shot

Upvotes: 0

Views: 78

Answers (3)

Shanto George
Shanto George

Reputation: 994

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_color_grey_500"
android:orientation="vertical" >

Upvotes: 1

tahsinRupam
tahsinRupam

Reputation: 6396

In your parent LinearLayout, Replace this :

 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="@color/main_color_grey_500"
  android:orientation="vertical" >

With this:

   <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parentt"
    android:background="@color/main_color_grey_500"
    android:orientation="vertical" >

Set, layout_height to match_parent and it will be fixed.

Upvotes: 1

Komal12
Komal12

Reputation: 3348

Change layout_height wrap_content to match_parent

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/main_color_grey_500"
    android:orientation="vertical" >
    .
    .
    .
    </LinearLayout>

Upvotes: 1

Related Questions