2013-03-28 5 views
0

У меня есть макет XML-файл:Назад Кнопка изображения не доступна?

<?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> 

BackButton образом я пытаюсь установить из макета является:

<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 файл

Может ли кто-нибудь сказать, что размещение кнопки изображения верна из моего файла макета?

ответ

3

Я думаю, что ваш линейный макет находится над изображением, и поэтому вы не можете получить доступ к ImageButton.

EDIT

<?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> 
+0

я исправить, Не могли бы вы сказать мне, как изменить? – String

+0

Да, я могу сказать вам, если вы скажете мне, какой тип макета желательно? эскиз или что-то еще .. –

+0

Я хочу разместить большие изображения на этом макете с горизонтальным прокруткой – String

Смежные вопросы