2017-01-20 45 views
0

我試圖陰影文本視圖像這樣: enter image description here文本視圖

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:gravity="top|center" 
    android:background="@drawable/gradient"> 
     <TextView 
      android:layout_width="300dp" 
      android:layout_height="50dp" 
      android:text="@string/ph" 
      style="@style/TextBox" 
      android:textSize="16sp"/> 
</LinearLayout> 

gradient.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item> 
    <shape android:shape="rectangle"> 
     <gradient 
      android:endColor="#FFFFFF" 
      android:startColor="#FFFFFF" 
      android:type="linear" 
      android:centerColor="#E3F2FD" 
      android:angle="90"> 
     </gradient> 

    </shape> 
</item> 

此代碼不能得到我的設計。是否有可能像我的照片textview?

+0

http://stackoverflow.com/questions/2486936/android-shadow-on-text –

+0

試圖在9batch圖像9修補圖像 –

+0

是tried.but這樣做不能得到明確這樣的.. – RamChithra

回答

0

在這裏,我試圖創建相同的陰影作爲您的要求,看起來像這樣。我知道,如u想

enter image description here

<LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:background="@drawable/shadow" 
     android:orientation="vertical" 
     android:paddingBottom="5dp"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/rectangle_shape" 
      android:padding="10dp" 
      android:text="Phone Number" /> 
    </LinearLayout> 

繪製/ shadow.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#220000ff" /> 
    <corners android:radius="20dp" /> 
</shape> 

繪製/ rectangle_shape.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#FFFFFF" /> 
    <corners android:radius="20dp" /> 
</shape> 
0

使XML backround_with_shadow陰影顏色不模糊並粘貼此代碼 -

<?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
     <item > 
      <shape 
       android:shape="rectangle"> 
       <solid android:color="#87ceeb" /> 
       <corners android:radius="5dp"/> 
      </shape> 
     </item> 
and set xml as background of layout 
     <item android:right="1dp" android:left="1dp" android:bottom="2dp"> 
      <shape 
       android:shape="rectangle"> 
       <solid android:color="@android:color/white"/> 
       <corners android:radius="5dp"/> 
      </shape> 
     </item> 
    </layer-list> 
+0

我想模糊像這樣的textview背景。 – RamChithra