我是Android开发的初学者,我使用Android studio创建了示例视图。但是当我运行时没有给出正确的put.please时,请参考下面的图片。
我创建我的主页LayOut作为右图。但是当我运行Come View Like Left Hand Picture.I运行不同的模拟器但输出是相同的。请希望得到一些专家的帮助。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.17">
<ImageButton
android:layout_width="136dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonService"
android:layout_gravity="center_horizontal"
android:layout_weight="0.17"
android:src="@drawable/services"
android:background="@null"
android:layout_marginBottom="36dp"
android:layout_above="@+id/imageButtontransaction"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="25dp"
android:layout_marginStart="25dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Service"
android:id="@+id/textView"
android:layout_alignTop="@+id/tvProfile"
android:layout_alignRight="@+id/imageButtonService"
android:layout_alignEnd="@+id/imageButtonService"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp" />
<ImageButton
android:layout_width="136dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonProfile"
android:layout_gravity="center_horizontal"
android:layout_weight="0.17"
android:src="@drawable/profile"
android:background="@null"
android:layout_alignTop="@+id/imageButtonService"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="58dp"
android:layout_marginEnd="58dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Profile"
android:id="@+id/tvProfile"
android:layout_alignBottom="@+id/imageButtonService"
android:layout_alignRight="@+id/imageButtonProfile"
android:layout_alignEnd="@+id/imageButtonProfile"
android:layout_marginRight="26dp"
android:layout_marginEnd="26dp" />
<ImageButton
android:layout_width="136dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtontransaction"
android:layout_gravity="center_horizontal"
android:layout_weight="0.17"
android:src="@drawable/transaction"
android:background="@null"
android:layout_alignTop="@+id/imageButtonwallet"
android:layout_alignRight="@+id/tvTransaction"
android:layout_alignEnd="@+id/tvTransaction" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Transaction"
android:id="@+id/tvTransaction"
android:layout_marginBottom="97dp"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/imageButtonService"
android:layout_alignEnd="@+id/imageButtonService" />
<ImageButton
android:layout_width="136dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonwallet"
android:layout_gravity="center_horizontal"
android:layout_weight="0.17"
android:src="@drawable/wallet"
android:background="@null"
android:layout_above="@+id/tvWallet"
android:layout_alignRight="@+id/imageButtonProfile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Wallet"
android:id="@+id/tvWallet"
android:layout_alignTop="@+id/tvTransaction"
android:layout_alignLeft="@+id/tvProfile"
android:layout_alignStart="@+id/tvProfile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Welcome SCPP Home"
android:id="@+id/tvWelcom"
android:layout_above="@+id/imageButtonService"
android:layout_alignRight="@+id/tvProfile"
android:layout_alignEnd="@+id/tvProfile"
android:layout_marginBottom="36dp" />
</RelativeLayout>
</LinearLayout>
我的活动类。
public class Home extends Activity implements View.OnClickListener{
private final int SPLASH_DISPLAY_LENGTH = 2000;
private ImageButton profileimgButton;
private ImageButton transctionimgButton;
private ImageButton walletimgButton;
private ImageButton serviceimgButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
initUi();
}
private void initUi() {
profileimgButton = (ImageButton) findViewById(R.id.imageButtonProfile);
transctionimgButton=(ImageButton) findViewById(R.id.imageButtontransaction);
walletimgButton=(ImageButton) findViewById(R.id.imageButtonwallet);
serviceimgButton=(ImageButton) findViewById(R.id.imageButtonService);
profileimgButton.setOnClickListener(Home.this);
transctionimgButton.setOnClickListener(Home.this);
walletimgButton.setOnClickListener(Home.this);
serviceimgButton.setOnClickListener(Home.this);
}
}