Android 在同一空间中几乎没有包含
如中所示,profile_内容布局占用了整个可用空间,当我按下profile按钮时,信息显示正确 但当我按下信息按钮时,它不会显示任何内容。正如您在中所看到的,蓝色矩形不像profile_内容布局那样填充整个空间 在android:layout\u widt参数中,这两个布局具有相同的值wrap\u content 我有一些代码,比如:Android 在同一空间中几乎没有包含,android,android-layout,Android,Android Layout,如中所示,profile_内容布局占用了整个可用空间,当我按下profile按钮时,信息显示正确 但当我按下信息按钮时,它不会显示任何内容。正如您在中所看到的,蓝色矩形不像profile_内容布局那样填充整个空间 在android:layout\u widt参数中,这两个布局具有相同的值wrap\u content 我有一些代码,比如: public void onClick(View v) { switch(v.getId()){ case R.id.b
public void onClick(View v) {
switch(v.getId()){
case R.id.bProfile:
Log.d(TAG, "onClick, buttonProfile pressed");
//Hide previous layout
activeLayout = "bProfile";
profileContent.setVisibility(View.VISIBLE);
//Access for extras passed in from login activity
tUserName.setText(getIntent().getStringExtra("tProfileName"));
break;
case R.id.bMessages:
Log.d(TAG, "onClick, buttonMessages pressed");
profileContent.setVisibility(View.INVISIBLE);
messagesContent.setVisibility(View.VISIBLE);
activeLayout = "bMessages";
test.setText("Test");
break;
}
}
也许我应该使用FragmentLayout来实现这个特定的功能
提前谢谢。线性布局在这种情况下帮不了你。尝试使用RelativeLayout,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/buttonsMenu"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QWERTY" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QWERTY" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ASDFG" />
</LinearLayout>
<RelativeLayout
android:layout_toRightOf="@id/buttonsMenu"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/profile_content"
layout="@layout/profile_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<include
android:id="@+id/profile_content"
layout="@layout/messages_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
发布您的xml代码