Back Image按钮不可点击?
问题描述:
我有我的布局xml文件:Back Image按钮不可点击?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/screen_background">
<ImageButton
android:id="@+id/back_btn"
android:layout_width="30dp"
android:layout_height="190dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="-5dp"
android:background="@drawable/button_movielist_back"
/>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignBottom="@+id/linearLayout01"
android:layout_marginBottom="55dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:src="@drawable/tone_movies_banner"
android:layout_alignParentTop="true"
android:scaleType="fitXY"/>
<HorizontalScrollView
android:id="@+id/horizontalScroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/actionBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_action_movies"
android:onClick="btnClicker"/>
<Button
android:id="@+id/comedyBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_comedy_movies"
android:onClick="btnClicker" />
<Button
android:id="@+id/loveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_love_movies"
android:onClick="btnClicker" />
</LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/linearLayout01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp">
</LinearLayout>
</LinearLayout>
</RelativeLayout>
的返回按钮图像我试图从布局设置为:
<ImageButton
android:id="@+id/back_btn"
android:layout_width="30dp"
android:layout_height="190dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="-5dp"
android:background="@drawable/button_movielist_back"
/>
代码:
// Previous Button
ImageButton backBtn = (ImageButton) findViewById(R.id.back_btn);
backBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(v.getContext(), "Hello!! button Clicked", Toast.LENGTH_SHORT).show();
//Intent i = new Intent(getBaseContext(), SpecificationsActivity.class);
//i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
//ShortfilmCategoryviewActivity.this.startActivity(i);
}
});
当我点击backimagebutton ,它不可点击
我认为问题persi st在布局xml文件中
任何人都可以告诉我从我的布局文件放置imagebutton是否正确?
答
我认为你的线性布局是在imageButton上方,这就是为什么你不能访问ImageButton。
编辑
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/screen_background">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignBottom="@+id/linearLayout01"
android:layout_marginBottom="55dp">
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:src="@drawable/tone_movies_banner"
android:layout_alignParentTop="true"
android:scaleType="fitXY"/>
<HorizontalScrollView
android:id="@+id/horizontalScroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/actionBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_action_movies"
android:onClick="btnClicker"/>
<Button
android:id="@+id/comedyBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_comedy_movies"
android:onClick="btnClicker" />
<Button
android:id="@+id/loveBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_love_movies"
android:onClick="btnClicker" />
</LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/linearLayout01"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp">
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/back_btn"
android:layout_width="30dp"
android:layout_height="190dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="-5dp"
android:background="@drawable/button_movielist_back"
/>
</RelativeLayout>
雅改正的,你能告诉我怎么改? – String 2013-03-28 11:10:48
是的,我可以告诉你,如果你告诉我什么类型的布局是理想的?一个草图或其他东西.. – 2013-03-28 11:13:12
我想放置在这个布局与水平滚动大尺寸图像 – String 2013-03-28 11:15:20