Friday, December 17, 2010

Android android:layout_toRightOf, android:layout_alignParentRight="true" simple

Android iin View г байршуулж байгаа жишээ

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/shape">
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/tv_name"
            android:text="Name"></TextView>
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Description"
            android:id="@+id/tv_description"
            android:layout_toRightOf="@+id/tv_name"
            android:layout_marginLeft="10px"
            />
    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/iv_forward"
            android:background="@drawable/forward_arrow"
            android:layout_alignParentRight="true"
            />
</RelativeLayout>





goob simple layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/news_new_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingTop="2px"
        android:paddingBottom="6px"
        android:background="@drawable/item_back_lightgrey_red_inner"
        >
    <ImageView
            android:id="@+id/news_new_image"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_marginTop="4px"
            android:layout_marginLeft="2px"
            android:layout_marginRight="4px"
            android:layout_marginBottom="2px"
            />
    <TextView
            android:id="@+id/news_new_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="@style/StyleTextBold14"
            android:textColor="@drawable/color_black_white"
            android:layout_alignParentTop="true"
            android:layout_toRightOf="@+id/news_new_image"
            android:duplicateParentState="true"
            />
    <TextView
            android:id="@+id/news_new_date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="10px"
            android:textColor="@drawable/color_black_white"
            android:layout_toRightOf="@+id/news_new_image"
            android:layout_below="@+id/news_new_name"
            android:duplicateParentState="true"
            />
    <TextView
            android:id="@+id/news_new_site"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="10px"
            android:textColor="@drawable/color_black_white"
            android:layout_below="@+id/news_new_name"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10px"
            android:duplicateParentState="true"
            />
</RelativeLayout>

No comments: