2012-06-27 71 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"