2016-04-25 18 views
2

world!私は学生で、自分の国についてのAndroidアプリケーションを開発しています。私はアプリで美しいレイアウトに気づいた。この絵で A text is over image at the bottom with background gradientAndroid。画像に効果を加えたテキストを追加する

、あなたがそれを行うか、方向を示す方法を見つけ出すために私を助けることができる場合、私は思っていた美しい背景(グラデーションの一種) の画像の底部に配置されたtextviews。 今では、このために私が持っているすべて: row.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="200dp" 
    android:layout_marginBottom="5dp" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
     <ImageView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:src="@drawable/medeobase" 
      android:scaleType="fitXY" 
      android:id="@+id/place_image" 
      /> 
     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:layout_alignParentBottom="true" 
      android:background="#AA000000"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Medeu" 
       android:id="@+id/place_id" 
       android:layout_marginLeft="20dp" 
       android:layout_marginTop="2dp" 
       android:textSize="18sp" 
       android:textColor="@color/colorWhite"/> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Almaty region" 
       android:textColor="@color/colorPrimary" 
       android:layout_marginLeft="20dp" 
       android:layout_below="@+id/place_id" 
       android:textSize="12sp" 
       android:id="@+id/place_id_sub" 

       /> 
     </RelativeLayout> 
    </RelativeLayout> 

ありがとう!

答えて

4

TextViewを保持しているRelativeLayoutのバックグラウンドに実際にはGradientDrawableを使用します。

勾配がこのようなものになります:

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/my_custom_gradient.xml"> 

:このように、勾配を使用してRelativeLayoutの背景色を置き換えるその後

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <gradient 
     android:angle="90" 
     android:endColor="@android:color/transparent" 
     android:startColor="@android:color/black" /> 
</shape> 

my_custom_drawable.xmlをこれにより、次のようになります。

GradientDrawableの色はあなたのニーズに合ったものにする必要があります。私はあなたの必要性のためにどのような色が正しいかを教えてくれません。

centerColorを追加することもできます。詳細はdocumentationをご覧ください。

おそらく、サブタイトルのtextcolorをタイトルのtextcolorと同じ色に変更します。

+0

ありがとうございます:)それは私を助けました!申し訳ありませんが私の評価が不十分なので、私はあなたが答えをupvoteすることはできません。 –

+0

@ ZhadyrassynDaniyar問題はありません:-)私はあなたがまだ評判なしでも答えとしてそれを受け入れることができると思います:-) – Darwind

関連する問題