您好我已经创建了一个滑动抽屉并创建了一个可滚动的xml文件,当用户点按滑动抽屉内的按钮时,我希望这个文件会膨胀。但是,当按下按钮时,除了空白屏幕之外没有任何显示。谁能告诉我我做错了什么? 这是我的代码: XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/text2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:text="@string/text2" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10sp"
android:adjustViewBounds="true"
android:src="@drawable/image"/>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="5sp"
android:layout_marginTop="10sp"
android:text="@string/text1" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10sp"
android:adjustViewBounds="true"
android:src="@drawable/image1"/>
</LinearLayout>
和java:
next3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getLayoutInflater().inflate(R.layout.activity, null);
slider.animateClose();
}
});
请帮忙!
答案 0 :(得分:0)
该行
getLayoutInflater().inflate(R.layout.activity, null);
创建(膨胀)布局文件的内容,但您没有将返回的视图放在任何位置。
您想将ScrollView放入滑动抽屉吗?如果是,请更改为:
getLayoutInflater().inflate(R.layout.activity, slider);