is there nobody who can help me? 2010/4/17 Marco Alexander Schmitz <[email protected]>
> Hi you all, > > today I've got a silly little problem and I hope you can help me out. > > I want to create a big button that contains a bitmap and some text. > > So I created a container (LinearLayout) with clickable="true". > > Inside this container there is an ImageButton with > duplicateParentState="true" and a TextView. > > The problem is that I can click everywhere in this container except on > the ImageButton. > > > In order to show that something is clicked I use an xml (with selector > and items) as background for the ImageView. > > > If you remove the clickable="true" and duplicateParentState="true" > only the the ImageButton is clickable. > > How can I create such a big button as I want to? > > > Here comes some code: > > First of all the button_green.xml with 2 different bitmaps: > > <?xml version="1.0" encoding="utf-8"?> > <selector xmlns:android="http://schemas.android.com/apk/res/android"> > > <item android:state_focused="false" android:state_pressed="false" > android:drawable="@drawable/button_green_normal" /> > > <item android:state_focused="true" android:state_pressed="false" > android:drawable="@drawable/button_green_normal" /> > > <item android:state_focused="false" android:state_pressed="true" > android:drawable="@drawable/button_green_hover" /> > > <item android:state_focused="true" android:state_pressed="true" > android:drawable="@drawable/button_green_hover" /> > > </selector> > > And then the main.xml with a top image and two big buttons: > > <?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="fill_parent" > android:background="#141414"> > > <ImageView android:id="@+id/top" > android:layout_width="wrap_content" > android:layout_height="wrap_content" android:src="@drawable/ > top" > android:layout_alignParentTop="true" /> > > <!-- important here: android:clickable="true" --> > <LinearLayout android:id="@+id/bigbutton_1" > android:layout_below="@+id/top" > android:layout_width="250dip" > android:layout_height="100dip" android:background="@drawable/ > bigbutton" > android:layout_centerHorizontal="true" > android:layout_marginTop="25dip" > android:clickable="true"> > > <!-- important here: android:duplicateParentState="true" --> > <ImageButton android:id="@+id/green_button" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:background="@drawable/button_green" > android:layout_gravity="center_vertical" > android:duplicateParentState="true" /> > > <TextView android:layout_width="wrap_content" > android:layout_height="wrap_content" android:text="You > can click me !" > android:layout_gravity="center_vertical" > android:textColor="#BBB5A5" > android:textSize="18dip" /> > </LinearLayout> > > <!-- important here: android:clickable="true" --> > <LinearLayout android:id="@+id/bigbutton_2" > android:layout_below="@+id/bigbutton_1" > android:layout_width="250dip" > android:layout_height="100dip" android:background="@drawable/ > bigbutton" > android:layout_centerHorizontal="true" > android:layout_marginTop="25dip" > android:clickable="true"> > > <!-- important here: android:duplicateParentState="true" --> > <ImageButton android:id="@+id/green_button" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:background="@drawable/button_red" > android:layout_gravity="center_vertical" > android:textColor="#BBB5A5" android:textSize="18dip" > android:duplicateParentState="true" /> > > <TextView android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:text="Click me, too !" > android:layout_gravity="center_vertical" > android:textColor="#BBB5A5" > android:textSize="18dip" /> > </LinearLayout> > > </RelativeLayout> > > Thanks for your help. > > I'll attach the project so you can play around... > > Greetings, > Marco > > Screenshot: http://www.anddev.org/files/screenshot_652.png > Project: http://www.anddev.org/download.php?id=2058 > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

