1
在两个LinearLayouts页眉和页脚中的主要活动如何隐藏滚动页眉和页脚中的Android
也RecyclerView内swipeRefreshLayout它们之间
现在我想隐藏页眉和页脚使用LayoutParam,但它显示更改layoutParam后的差距,swipeRefreshLayout的高度不会更改。
如何解决?
在两个LinearLayouts页眉和页脚中的主要活动如何隐藏滚动页眉和页脚中的Android
也RecyclerView内swipeRefreshLayout它们之间
现在我想隐藏页眉和页脚使用LayoutParam,但它显示更改layoutParam后的差距,swipeRefreshLayout的高度不会更改。
如何解决?
我试图解决您的问题使用演示。
XML文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:onClick="click"
android:background="#fffe4a" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="2dp"
android:background="#3489ff" />
<View
android:id="@+id/view_bottom"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#fffe4a" />
</LinearLayout>
java文件。
package com.example.wangze.instantdemo1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void click(View view){
View view_bottom = findViewById(R.id.view_bottom);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view_bottom.getLayoutParams();
layoutParams.height = 20;
view_bottom.setLayoutParams(layoutParams);
}
}
当我点击顶视图。底部较小,没有间隙。也许它可以帮助你。