2016-03-31 145 views
-1

這是我的xml:耕用位圖XML格式的圖像不起作用

<?xml version="1.0" encoding="utf-8"?> 

<ImageView 
    android:id="@+id/up_margin" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ticket_up_tile"/> 

<RelativeLayout 
    android:id="@+id/container" 
    android:layout_below="@id/up_margin" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/white" 
    android:layout_margin="10dp"> 

    <TextView 
     android:id="@+id/origin" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textColor="@color/gray32" 
     android:textSize="17dp"/> 

    <TextView 
     android:id="@+id/destination" 
     android:layout_below="@id/origin" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:translationY="-5dp" 
     android:textColor="@color/gray32" 
     android:textSize="17dp"/> 

    <TextView 
     android:id="@+id/title" 
     android:layout_below="@id/destination" 
     android:layout_marginTop="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textColor="@color/gray32" 
     android:textSize="28dp" 
     android:text="@string/intro.mileage"/> 

    <View 
     android:id="@+id/line1" 
     android:layout_marginTop="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="0.5dp" 
     android:layout_below="@id/title" 
     android:background="@color/gray32"/> 

    <RelativeLayout 
     android:layout_marginTop="10dp" 
     android:layout_below="@id/line1" 
     android:id="@+id/prices_container" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

    </RelativeLayout> 

    <View 
     android:id="@+id/line2" 
     android:layout_marginTop="10dp" 
     android:layout_width="match_parent" 
     android:layout_height="0.5dp" 
     android:layout_below="@id/prices_container" 
     android:background="@color/gray32"/> 

    <TextView 
     android:id="@+id/dismiss" 
     android:layout_below="@id/line2" 
     android:textColor="@color/background" 
     android:padding="10dp" 
     android:layout_centerHorizontal="true" 
     android:text="@string/Dismiss" 
     android:gravity="center_horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 
<ImageView 
    android:id="@+id/down_margin" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/container" 
    android:src="@drawable/ticket_down_tile"/> 

我在開頭和結尾的圖片,我需要平鋪。 我設置就可以了,我創建了一個繪製:

<bitmap 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:tileMode="repeat" 
android:src="@drawable/popup_ticket_up"/> 

正如你看到的,但對重複TILEMODE。此外,imageViews,都在寬度匹配parrent。 這是我得到的結果: As you can see, it does not tile

回答

1

設置bitmap作爲background您的容器(或在View你想要的),而不是將其添加爲srcImageView