我怎麼能做到這樣的一個按鈕,如下顯示視圖相對於Android的
顯示的圖像,所以我想的是,一旦我做出點擊或長的一個任意的按鈕我想說明一個佈局的按鈕是頂部contaning幾個按鈕點擊
我有以下XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="showme"
android:id="@+id/button36"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="showme"
android:id="@+id/button37"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="showme"
android:id="@+id/button38"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4">
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button39"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button40"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button41"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button42"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4" >
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button43"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button44"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button45"
android:layout_weight="1" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="clickme"
android:id="@+id/button46"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
所以基本上我有第一的LinearLayout containings名爲「SHOWME」,我想相對於展示給任何按鈕的頂部位置,我從過去兩年的LinearLayout命名點擊按鈕「clickme 」。
我想我應該在java代碼中做到這一點,但我只是無法弄清楚如何在xml佈局中實現它。
你甚至看問題的XML風格???你的ans與這個問題無關 –
@neo因爲Zahan Safallwa說這不是我所要求的。我的問題是在佈局本身而不是如何setonlongclicklistener – has19
@Neo彈出菜單是垂直我需要他們horizentally與我自己的佈局。我想通過簡單地使用被點擊的按鈕的x和y位置來顯示它們,並添加我想要的關於這些位置的視圖.thx無論如何 – has19