-1

I am new in android app development.I am doing a project in android. I have set a image in background such that it will be see in other part of cardview.If anyone knows, please share your answer.My XML code is below

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

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:background="#FFFFFF"
    android:src="@drawable/images1"/> 
<android.support.v7.widget.CardView
    android:orientation = "vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/RateMe"
            android:text="Rate your experience?"
            android:layout_marginLeft="40dp"
            android:background="#FFFFFF"
            android:textAppearance="@android:style/TextAppearance.Large"/>
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ratingBar"
            android:numStars="5"
            android:layout_marginLeft="40dp"
            android:stepSize="0.1" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Cleaniness"
            android:text="How was cleaniness?"
            android:layout_marginLeft="40dp"
            android:textAppearance="@android:style/TextAppearance.Large"/>
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/RateClean"
            android:numStars="5"
            android:layout_marginLeft="40dp"
            android:stepSize="0.1" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Comment"
            android:layout_marginLeft="40dp"
            android:hint="please enter comment here" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/bttn"
            android:hint="Submit"
            android:layout_marginLeft="40dp"
            android:layout_gravity="center" />
        </LinearLayout>
    </android.support.v7.widget.CardView></LinearLayout>
Dipu
  • 45
  • 1
  • 2
  • 16

2 Answers2

0

If you want to make your activity transparent then check this answer - How do I create a transparent Activity on Android?

Community
  • 1
  • 1
Passiondroid
  • 1,573
  • 1
  • 16
  • 28
0

Why don't you try to make your LinearLayout the color you want, and the cardView with a transparent background. With your code you should have something like this

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/bg">

<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:orientation = "vertical"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    card_view:cardCornerRadius="5dp"
    card_view:cardElevation="5dp"
    card_view:cardBackgroundColor="#55FFFFFF">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/RateMe"
            android:text="Rate your experience?"
            android:layout_marginLeft="40dp"
            android:textAppearance="@android:style/TextAppearance.Large"/>
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/ratingBar"
            android:numStars="5"
            android:layout_marginLeft="40dp"
            android:stepSize="0.1" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Cleaniness"
            android:text="How was cleaniness?"
            android:layout_marginLeft="40dp"
            android:textAppearance="@android:style/TextAppearance.Large"/>
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/RateClean"
            android:numStars="5"
            android:layout_marginLeft="40dp"
            android:stepSize="0.1" />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/Comment"
            android:layout_marginLeft="40dp"
            android:hint="please enter comment here" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/bttn"
            android:hint="Submit"
            android:layout_marginLeft="40dp"
            android:layout_gravity="center" />
    </LinearLayout>
</android.support.v7.widget.CardView>

Chakir
  • 488
  • 4
  • 10
  • When I add a image in background it overlaps the card view.I want to UI such that part of image should be see in other part of cardview. – Dipu Mar 18 '17 at 11:31
  • @Dipu Kumar I've edited the code to use a FrameLayout and changing the alpha of the CardView background. Maybe i don't get exactly what you want. If this code don't solve your problem, please add a comment with an exemple of what you want. Thanks – Chakir Mar 18 '17 at 12:49