如何在背景中设置图像,以便在 cardview 的其他部分看到它?
How to set an Image in background such that it will be see in other part of cardview?
我是 android 应用程序的新手 development.I 我正在 android 做一个项目。我在背景中设置了一张图片,以便在 cardview.If 的其他部分看到任何人知道,请分享您的 answer.My XML 代码如下
<?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>
如果你想让你的 activity 透明然后检查这个答案 - How do I create a transparent Activity on Android?
你为什么不尝试让你的 LinearLayout 成为你想要的颜色,并让 cardView 具有透明背景。使用你的代码你应该有这样的东西
<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>
我是 android 应用程序的新手 development.I 我正在 android 做一个项目。我在背景中设置了一张图片,以便在 cardview.If 的其他部分看到任何人知道,请分享您的 answer.My XML 代码如下
<?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>
如果你想让你的 activity 透明然后检查这个答案 - How do I create a transparent Activity on Android?
你为什么不尝试让你的 LinearLayout 成为你想要的颜色,并让 cardView 具有透明背景。使用你的代码你应该有这样的东西
<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>