Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexlayout隐藏子控件之后,子控件仍然占用空间 #16

Open
dxp2020 opened this issue Oct 16, 2017 · 4 comments
Open

Flexlayout隐藏子控件之后,子控件仍然占用空间 #16

dxp2020 opened this issue Oct 16, 2017 · 4 comments

Comments

@dxp2020
Copy link

dxp2020 commented Oct 16, 2017

我给子控件添加了属性 android:visibility="gone",结果控件隐藏了,但控件仍然占用了空间,效果是跟 android:visibility="invisible"一样的

@dxp2020 dxp2020 changed the title Flexlayout隐藏子控件之后,子控件仍然占用控件 Flexlayout隐藏子控件之后,子控件仍然占用空间 Oct 16, 2017
@mmin18
Copy link
Owner

mmin18 commented Oct 16, 2017

能把具体的代码贴上来看一下吗

@dxp2020
Copy link
Author

dxp2020 commented Oct 16, 2017

TextView
android:id="@+id/tv_high_speed_charge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_charge"
android:textColor="@color/color_999999"
android:visibility="gone"
app:layout_centerX="50%"
app:layout_top="prev.bottom+15dp"

就比如说这个控件,隐藏之后仍然占用了空间

@dxp2020
Copy link
Author

dxp2020 commented Oct 17, 2017

你们没有这种情况么

@mmin18
Copy link
Owner

mmin18 commented Oct 28, 2017

我试了一下好像没问题
fl

<?xml version="1.0" encoding="utf-8"?>
<com.github.mmin18.widget.FlexLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:app="http://schemas.android.com/apk/res-auto"
	android:layout_width="match_parent"
	android:layout_height="match_parent">

	<View
		android:layout_width="60dp"
		android:layout_height="60dp"
		android:background="#f00"
		app:layout_centerX="50%"
		app:layout_top="10dp"/>

	<TextView
		android:id="@+id/tv_high_speed_charge"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:text="tv_high_speed_charge"
		android:textColor="#fff"
		android:visibility="gone"
		app:layout_centerX="50%"
		app:layout_top="prev.bottom+15dp"/>

	<View
		android:layout_width="60dp"
		android:layout_height="60dp"
		android:background="#0f0"
		app:layout_centerX="50%"
		app:layout_top="tv_high_speed_charge.bottom"/>

	<Button
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:onClick="switchGone"
		android:text="switch"
		app:layout_centerX="50%"
		app:layout_centerY="50%"/>
</com.github.mmin18.widget.FlexLayout>
	public void switchGone(View v) {
		View g = findViewById(R.id.tv_high_speed_charge);
		g.setVisibility(g.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants