(我把代码放在帖子的末尾)
我想制作一个隐藏的菜单。
我不知道我是否采取了好的方式。
我有一些按钮可见,一些隐形按钮和另一个可见按钮。 第一个布局中的一个按钮必须设置可见的隐藏按钮。
我想在第一组之后有最后一个按钮。 但就像我把布局隐藏起来所以我有一个空的空间。
我想按下按钮设置可见,最后一个按钮按下。
我希望你能理解我想做的事情以及我所做的事情。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/fond"
>
<ImageView
android:id="@+id/imageView1"
android:contentDescription="@string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/top"
android:layout_gravity="top"
android:adjustViewBounds="true"
/>
<LinearLayout
android:layout_below="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/fond2"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="3"
>
<Button
android:id="@+id/button_garçon"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/Bg"
android:background="@drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionGarçon"
/>
<Button
android:id="@+id/button_mixte"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/Bm"
android:background="@drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionMixte"
/>
<Button
android:id="@+id/button_fille"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/Bf"
android:background="@drawable/button_purple"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionFille"
/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1"
>
<Button
android:id="@+id/button_param"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Bp"
android:background="@drawable/button_green"
android:layout_weight="1"
android:textColor="#ffffff"
android:onClick="actionParametre"
/>
</LinearLayout>
<!-- invisible -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Tq"
android:textColor="#000000"
/>
<EditText android:id="@+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/Emc"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Tpre"
android:textColor="#000000"
/>
<EditText android:id="@+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/Epre"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Tsuf"
android:textColor="#000000"
/>
<EditText
android:id="@+id/edit_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/Esuf"
android:singleLine="true"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Tl"
android:textColor="#000000"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100"
>
<Button android:id="@+id/button_court"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Blc"
android:layout_weight="25"
android:background="@drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionCourt"
/>
<Button android:id="@+id/button_moyen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Blm"
android:layout_weight="25"
android:background="@drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionMoyen"
/>
<Button android:id="@+id/button_long"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Bll"
android:layout_weight="25"
android:background="@drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionLong"
/>
<Button android:id="@+id/button_tous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Blt"
android:layout_weight="25"
android:background="@drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionTous"
android:state_pressed="true"
/>
</LinearLayout>
<Button android:id="@+id/button_orig"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Bo"
android:background="@drawable/button_purple"
android:textColor="#ffffff"
android:onClick="actionOrigine"
/>
</LinearLayout>
<!-- /invisible -->
<Button android:id="@+id/button_recher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Br"
android:background="@drawable/button_green"
android:textColor="#ffffff"
android:onClick="actionRecherche"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
提前致谢。
答案 0 :(得分:1)
如果我理解正确,您希望使用android:visibility="gone"
,这样您设置为"gone"
的内容就不会占用布局上的任何空间。
基本上,您应该使用android:visibility="invisible"
android:visibility="gone"
看看是否有效。