как использовать Z-индекс в Android - PullRequest
5 голосов
/ 10 ноября 2011
  <LinearLayout 
    android:orientation="vertical"
    android:layout_width="300dp"
    android:layout_height="50dp">
  <ImageView android:layout_height="40dp" android:id="@+id/imageView1" 
   android:background="@drawable/nicetab" 
   android:layout_width="300dp" ></ImageView>
    <TextView
        style="@style/DialogText.Title"
        android:id="@+id/title"
        android:paddingBottom="10dip"
        android:paddingLeft="45dip"
        android:paddingTop="7dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/codeFont" 
        android:textSize="15dip"
        />
</LinearLayout>

Как я могу поставить TextView на ImageView. Есть ли способ в Android сделать это, в HTML это слишком легко, мы используем z-index, но здесь - без понятия

Ответы [ 2 ]

6 голосов
/ 10 ноября 2011

Очень простой способ - использовать RelativeLayout

<RelativeLayout 
    android:orientation="vertical"
    android:layout_width="300dp"
    android:layout_height="50dp" >
    <ImageView
        android:layout_height="40dp"
        android:id="@+id/imageView1"
        android:background="@drawable/nicetab"
        android:layout_width="300dp" />
    <TextView
        style="@style/DialogText.Title"
        android:id="@+id/title"
        android:paddingBottom="10dip"
        android:paddingLeft="45dip"
        android:paddingTop="7dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/codeFont" 
        android:textSize="15dip" />
</RelativeLayout>
2 голосов
/ 20 марта 2013

Предлагаемый способ сделать текстовое представление поверх представления изображения состоит в том, чтобы использовать нарисованный текстовый вид.

android:drawable[Top|Left|Right|Bottom]="@your_drawable_here"

<TextView
    style="@style/DialogText.Title"
    android:id="@+id/title"
    android:paddingBottom="10dip"
    android:paddingLeft="45dip"
    android:paddingTop="7dip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/codeFont" 
    android:drawableTop="@drawable/your_drawable_from_imageview" 
    android:textSize="15dip" />

Я не уверен, что у вас в вашем стиле, так что если что дановыше не работает, попробуйте удалить стиль, или вставьте стиль здесь, и я помогу вам.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...