2016-01-14 3 views
0

Я пытаюсь разместить TextView над ImageView. Теперь я хочу установить видимость фона TextView на 40%. Это мой текущий статус.Установить видимость фона TextView в CardView

... 
<FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/framelayout"> 

     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/imageView"/> 

     <TextView 
      android:id="@+id/title" 
      android:layout_width="378dp" 
      android:layout_height="35dp" 
      android:background="#000000" 
      android:text="Caption" 
      android:gravity="start" 
      android:textColor="@android:color/white" 
      android:layout_marginTop="165dp" 
      android:textSize="30dp" 
      android:layout_alignBottom="@+id/imageView" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:visibility="visible" /> 

    </FrameLayout> 
... 

Может кто-нибудь Пожалуйста, руководствоваться мной, как мне с этим заняться?

ответ

1
<FrameLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/framelayout" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

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


<TextView 
    android:id="@+id/title" 
    android:layout_width="378dp" 
    android:layout_height="35dp" 
    android:background="#000000" 
    android:text="Caption" 
    android:gravity="start" 
    android:alpha="0.5" 
    android:textColor="@android:color/white" 
    android:layout_marginTop="30dp" 
    android:textSize="20sp" 

    /> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/title" 
    android:id="@+id/imageView" /> 

</RelativeLayout> 

</FrameLayout> 

Для настройки прозрачности необходимо использовать android:alpha="" свойство, а размер текста не в dp, его sp. Надеюсь, поможет. Счастливое кодирование!

+0

Ну, это было полезно! Огромное спасибо. –

Смежные вопросы