【问题标题】:Visibility of Gone takes still space of particular control in android?Gone 的可见性仍然需要 android 中的特定控制空间?
【发布时间】:2015-08-02 18:11:42
【问题描述】:

我正在使用 LinearLayout,并且在按钮内部,我正在根据支持的状态使可见性消失。 SupportedStatuses 为 true,然后将 Button 设为 Visible,但 SupprtedStatuse 为 false,然后将 button 设为 Gone。

这是在标题中,按钮已消失,但仍占用空间。 这是我正在使用的布局。

<LinearLayout
            android:id="@+id/llparentView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content
            android:orientation="vertical">
      <Button
            android:id="@+id/btn_change_status"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
</LinearLayout>

任何人都有一个好的解决方案,那么它对我有很大帮助。

【问题讨论】:

  • 您是否以编程方式更改可见性?
  • setVisibility 为线性布局而不是按钮
  • 是的.. 以编程方式更改可见性.. @ Blackbelt
  • 我无法将Visibilty设置为线性布局还有其他控件..
  • 我在同一个屏幕上并且存在问题

标签: android android-layout button android-linearlayout visibility


【解决方案1】:

您可以在您使用的任何布局周围使用 FrameLayout 例如:

<FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content">

    <!-- put your views here -->
</FrameLayout>

这将确保在使用 View.GONE 时 FrameLayout 折叠在空间上。

【讨论】:

    【解决方案2】:

    尝试将您的按钮包装在另一个线性/框架布局中,并更改它们的可见性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-02
      • 2013-04-16
      • 2013-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-24
      • 2015-08-30
      相关资源
      最近更新 更多