我必须显示CardView时,录音的Tap来编辑文本 TextView和点击外部将隐藏CardView。为了做到这一点,我尝试将CardView背景切换为透明和白色,但它没有工作。然后,我尝试将包含字母的EditText和CardView放在FrameLayout中,然后隐藏并显示CardView,但是CardView的背景样式在这样做时会变成透明的。您可以在下面找到我的xml。请告诉我这里发生了什么事?


XML
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_padding_2">
<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
app:cardCornerRadius="@dimen/box_radius"
app:cardElevation="0dp"
app:contentPadding="@dimen/margin_padding_2" />
<com.package.views.EditText
android:id="@+id/note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:cursorVisible="false"
android:gravity="start"
android:lineSpacingExtra="@dimen/margin_padding_1"
android:padding="@dimen/margin_padding_2"
android:textColor="@color/colorWhite"
android:textSize="@dimen/text_size_5"
app:textStyle="bold" />
</FrameLayout>码
private void controlView() {
mCard.setVisibility(View.VISIBLE);
mNote.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));
mNote.setCursorVisible(true);
mNote.setSelection(mNote.length());
}发布于 2016-04-01 09:05:19
试着使用
mCard.setCardBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));发布于 2016-04-01 09:24:17
若要以编程方式更改硬视图的颜色,您可以使用:
mCard.setCardBackgroundColor(Color.TRANSPARENT);在XML中执行
mCard:cardBackgroundColor="@android:color/transparent"https://stackoverflow.com/questions/36351605
复制相似问题