2012-06-27 75 views
0

嗨我有一個問題,把按鈕放在屏幕的底部我已經把它和在日食中的圖形佈局它看起來完全是我想要它,但是當我運行它在設備上,按鈕都會在相同位置的屏幕底部。所以只有一個按鈕是可見的。有沒有人知道這是爲什麼或者你知道如何將東西放在底部有一些填充?在屏幕底部的Android位置按鈕

繼承人什麼我都試過

<?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="@drawable/ic_background_credits" 
    android:orientation="vertical" > 

    <Button 
     android:id="@+id/fm" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="38dp" 
     android:background="@drawable/fmbtn" /> 

    <Button 
     android:id="@+id/ph" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/fm" 
     android:layout_alignLeft="@+id/fm" 
     android:background="@drawable/visitphbtn" /> 

</RelativeLayout> 

繼承人我的代碼,我誇大這種觀點

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    //Check Preferences which sets UI 
    setContentView(R.layout.singlenews); 
    findViewById(R.id.progress).setVisibility(View.GONE); 
    loadData(); 


     Button backbtn = (Button) findViewById(R.id.backbtn); 

     //Listening to button event 
     backbtn.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View arg0) { 
       //Starting a new Intent 
       Intent previousScreen = new Intent(getApplicationContext(), InfoActivity.class); 
       startActivity(previousScreen); 

      } 
     }); 


} 

public void loadData(){ 


    name = getIntent().getStringExtra("name"); 
    Log.v("lc", "infoname=" + name); 




    if (name.equals(name1")) { 

      NewsView = LayoutInflater.from(getBaseContext()).inflate(R.layout.infodetail, 
        null); 

     TextView headerText = (TextView) findViewById(R.id.header_text); 
     headerText.setText("About name1"); 

     TextView mainText = (TextView) NewsView.findViewById(R.id.maintext); 
     mainText.setText("name1"); 

     ImageView NewsImage = (ImageView)NewsView.findViewById(R.id.imageView2); 
     NewsImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_evostik)); 


    } 

    if (name.equals("name2")) { 

      NewsView = LayoutInflater.from(getBaseContext()).inflate(R.layout.infodetail, 
        null); 

     TextView headerText = (TextView) findViewById(R.id.header_text); 
     headerText.setText("About name2"); 

     TextView mainText = (TextView) NewsView.findViewById(R.id.maintext); 
     mainText.setText("name2"); 

     ImageView NewsImage = (ImageView)NewsView.findViewById(R.id.imageView2); 
     NewsImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_pitchero)); 


    } 


    if (name.equals("name3")) { 

      NewsView = LayoutInflater.from(getBaseContext()).inflate(R.layout.creditsdetail, 
        null); 


      TextView headerText = (TextView) findViewById(R.id.header_text); 
      headerText.setText("name3"); 


      Button phbtn=(Button)NewsView.findViewById(R.id.ph); 

      phbtn.setOnClickListener(new View.OnClickListener() { 

         public void onClick(View arg0) { 
          //Starting a new Intent 
          Uri uri = Uri.parse("http://www.pitchero.com"); 
          Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
          startActivity(intent); 


         } 
        }); 

      Button fmbtn=(Button)NewsView.findViewById(R.id.fm); 

      fmbtn.setOnClickListener(new View.OnClickListener() { 

         public void onClick(View arg0) { 
          //Starting a new Intent 
          Uri uri = Uri.parse("http://www.fantasticmedia.co.uk/mobile/"); 
          Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
          startActivity(intent); 


         } 
        }); 




     } 




    ListView list = getListView(); 
    list.setVerticalFadingEdgeEnabled(false); 



    Log.v("BGThread", "Filled results"); 

adapter = new MergeAdapter(); 

adapter.addView(NewsView); 


setListAdapter(adapter); 


} 



} 
+0

沒有看起來不合適的地方...你有沒有嘗試清理你的項目?從Eclipse轉到項目>清潔>選擇你的項目 – Guardanis

+0

我已經嘗試清洗它仍然是同一個問題 –

回答

0

其實我試試你的佈局我的項目,這兩個按鈕都放置正確。

你確定你沒有在你的代碼中做任何其他動作嗎?

1

我認爲你有一些混合起來的屬性。

在第二個按鈕中,不要將「+」運算符添加到id,因爲它正在創建一個新運算符。只要刪除它,並離開'@'。

記住'+'加入id和'@'引用它。

+0

我已經試過這個廣告它仍然在做同樣我真的很困惑PS我不知道,所以謝謝你教了我一些東西。 –

+0

不用擔心。如果它有助於upvote它。如果我的回答工作,請接受它。 –

+0

另外。 RelativeLayouts不採取方向,所以你可以擺脫這一點 –

0

相對佈局相對於RelativeLayout容器內的其他項目是一個ViewGroup。因此,例如,您可以在pm的描述中指定android:layout_leftOf =「@ + id/fm」。如果你想填充,你也可以像按鈕裏面那樣使用margin和padding來實現。

android:layout_marginBottom="20dip" 
android:layout_leftOf="@+id/fm" 
android:paddingBottom="10dip"