[英]how can i have a list of icons in my android app;
任何人都可以建議我如何在單擊圖標時列出瀏覽器圖標,電子郵件圖標和聯系人圖標等圖標的列表,它們應該分別導致android瀏覽器,電子郵件和聯系人應用程序...現在我單擊按鈕后就完成了。 現在我想要圖標(帶圖像和文字)而不是按鈕......
看一下這個:
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton
這將顯示您必須將您想要的圖像放在res / drawable /中,然后將它們作為按鈕加載到您的應用程序中。
沒有小部件圖標。 您可以使用LinearLayout
, ImageView
和TextView
自己進行操作。
xml應該是這樣的:
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/your_image"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/your_icon_text"/>
</LinearLayout>
我以為您想要ImageButton
,單擊要打開特定的應用程序/瀏覽器/聯系人列表。
ImageButton - 顯示一個按鈕,其中包含可由用戶按下或單擊的圖像(而不是文本)
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon/>
如果你想要ImageButton with Background按鈕,那么設置android:background
屬性,如下所示:
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:background="@drawable/background_image"/>
您可以使用Android Image Button並將其屬性設置為“Clickable = true”,並在其click事件偵聽器上執行所需的工作
如果你想在你的按鈕中使用圖像和文本,我的方法是創建一個9補丁,這樣我就可以使用填充和可伸展區域定義文本的去向。 然后按照與上述“自定義按鈕”相同的說明進行操作,但使用標准按鈕,而不是“圖像”按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.