我試圖設計UI,如下圖所示。這裏我想要設計兩個textViews和三個imageViews,如下所示。通過使用相對和線性 - 文本和可點擊圖像在Android設計UI
我試過,但將數據傳遞到textViews動態地將其錯誤地顯示之後(覆蓋在其他文本一文)
這是我的代碼:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="90dip"
android:orientation="horizontal"
android:padding="5dip" >
<!-- ListRow Left side navigation_image image -->
<LinearLayout
android:id="@+id/navigation_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="3dip" >
<ImageView
android:id="@+id/navigation_marker_image_view"
android:layout_width="30dip"
android:layout_height="30dip"
android:contentDescription="@string/navigation_image"
android:clickable="true"
android:focusable="false"
android:src="@drawable/navigation_marker" />
</LinearLayout>
<TextView
android:id="@+id/address_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/share_image_view"
android:layout_alignParentRight="true"
android:layout_below="@+id/date_time_text_view"
android:layout_toRightOf="@+id/navigation_image"
android:textSize="12sp" />
<TextView
android:id="@+id/date_time_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/address_text_view"
android:layout_alignParentRight="true"
android:textStyle="bold"
android:typeface="sans" />
<ImageView
android:id="@+id/share_image_view"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_alignTop="@+id/favourite_image_view"
android:layout_marginLeft="50dp"
android:layout_toRightOf="@+id/favourite_image_view"
android:contentDescription="@string/share_image"
android:clickable="true"
android:focusable="false"
android:src="@drawable/share" />
<ImageView
android:id="@+id/edit_image_view"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_alignLeft="@+id/address_text_view"
android:layout_alignParentBottom="true"
android:layout_marginLeft="29dp"
android:contentDescription="@string/edit_buttonon_image"
android:clickable="true"
android:focusable="false"
android:src="@drawable/edit" />
<ImageView
android:id="@+id/favourite_image_view"
android:layout_width="25dip"
android:layout_height="25dip"
android:layout_alignTop="@+id/edit_image_view"
android:layout_marginLeft="48dp"
android:layout_toRightOf="@+id/edit_image_view"
android:contentDescription="@string/favarouite_image"
android:clickable="true"
android:focusable="false"
android:src="@drawable/favourite" />
</RelativeLayout>
如何獲得corrrect設計如上所示,它應該正常工作。 在此先感謝..
得到這個類轉換異常: java.lang.ClassCastException:android.widget.ImageView不能投到android.widget.TextView –
類轉換可能是由喲引起的ü更改其中一個圖像視圖ids無論textview是什麼,我會編輯我的答案是更清晰 – triggs
嘿..感謝它的完美我想要的是..非常感謝.. :) –