0

i have a list item, in that i have certain text views and image views. The thing is that the design that i have got has three themes in it dark, brown and light. Now if I want to change the background of a list item to any of these three colors, how do I set the background. Like if i change the theme of the app from settings, the list item background should change. How am I suppose to make the themes with different backgrounds?

<LinearLayout 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="wrap_content"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/constraintLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="12dp"
        android:paddingEnd="16dp"
        android:paddingStart="16dp"
        android:paddingTop="12dp">

        <TextView
            android:id="@+id/company_name_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/montserratlight"
            android:text="Synergy Bizcon"
            android:textColor="@color/textColorMediumThemeDark"
            android:textSize="@dimen/fontMedium"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ImageView
            android:id="@+id/schedule_imageview"
            android:layout_width="10dp"
            android:layout_height="10dp"
            android:layout_marginTop="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/company_name_textview"
            app:srcCompat="@drawable/ic_watch" />

        <TextView
            android:id="@+id/date_time_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="6dp"
            android:layout_marginTop="4dp"
            android:fontFamily="@font/montserratlight"
            android:text="26 Apr 11:10 PM"
            android:textColor="@color/textColorSmallThemeDark"
            android:textSize="@dimen/fontExtraSmall"
            app:layout_constraintStart_toEndOf="@id/schedule_imageview"
            app:layout_constraintTop_toBottomOf="@id/company_name_textview" />

        <TextView
            android:id="@+id/pipe_textview"
            android:layout_width="0.5dp"
            android:layout_height="12dp"
            android:layout_marginStart="6dp"
            android:background="@color/textColorSmallThemeDark"
            app:layout_constraintBottom_toBottomOf="@id/date_time_textview"
            app:layout_constraintStart_toEndOf="@id/date_time_textview"
            app:layout_constraintTop_toTopOf="@id/date_time_textview" />

        <TextView
            android:id="@+id/exhcange_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="6dp"
            android:fontFamily="@font/montserratlight"
            android:text="BSE"
            android:textColor="@color/textColorSmallThemeDark"
            android:textSize="@dimen/fontExtraSmall"
            app:layout_constraintBottom_toBottomOf="@id/pipe_textview"
            app:layout_constraintStart_toEndOf="@id/pipe_textview"
            app:layout_constraintTop_toTopOf="@id/pipe_textview" />

        <TextView
            android:id="@+id/rate_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:fontFamily="@font/montserratlight"
            android:text="34567.58"
            android:textColor="@color/textColorMediumThemeDark"
            android:textSize="@dimen/fontMedium"
            app:layout_constraintEnd_toStartOf="@id/add_imageview"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/points_change_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:fontFamily="@font/montserratlight"
            android:text="-21.10(-0.02%)"
            android:textColor="@color/textColorSmallThemeDark"
            android:textSize="@dimen/fontExtraSmall"
            app:layout_constraintEnd_toEndOf="@id/rate_textview"
            app:layout_constraintTop_toBottomOf="@id/rate_textview" />

        <ImageView
            android:id="@+id/add_imageview"
            android:layout_width="16dp"
            android:layout_height="16dp"
            android:tint="@color/iconsColor"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/ic_add" />

    </android.support.constraint.ConstraintLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="0.2dp"
        android:background="@color/listItemDivider" />

</Linear Layout>

Like i have this list item, i want to change constraint layouts background to may be dark or brown or light. I would eventually use style to give the background, but i do not know how? Can someone help? Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Tsar
  • 63
  • 2
  • 10

0 Answers0