【问题标题】:Buttons not clickable in the upper half上半部分不可点击的按钮
【发布时间】:2019-05-24 16:24:54
【问题描述】:

嵌套在协调器布局中的fragment 中的以下按钮display_current_monthdisplay_current_year 在上半部分不可点击。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_custom_calendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp">

<Button
    android:id="@+id/display_current_month"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"/>

<Button
    android:id="@+id/display_current_year"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toEndOf="@id/display_current_month"
    android:layout_marginTop="15dp"/>

<LinearLayout
    android:id="@+id/calendar_days_of_week"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/display_current_month"
    android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>

协调器布局:

<android.support.design.widget.AppBarLayout
android:id="@+id/reminders_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_rounded_rectangle">

<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/reminders_collapsing_toolbar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:contentScrim="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|exitUntilCollapsed">

    <android.support.v4.view.ViewPager
        android:id="@+id/calendar_view"
        android:layout_width="match_parent"
        android:layout_height="380dp"
        android:layout_margin="5dp"
        app:layout_collapseMode="parallax" />

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

附上带有实际按钮的屏幕截图。非常感谢任何帮助。

附:按钮似乎有一个底部填充,允许在其边框下方约 10 dp 处单击按钮。

【问题讨论】:

    标签: android xml button layout


    【解决方案1】:

    您的视图寻呼机位于您的工具栏下方,这就是为什么您无法点击您的按钮,而您的工具栏将获得屏幕的触摸。 您可以将以下代码放入 xml 中的 ViewPager 标记中。

    android:layout_marginTop="?android:attr/actionBarSize"
    

    【讨论】:

    • 如何同时修复按钮下部的可点击区域?这些按钮似乎在它们的边框下方有一个填充(可点击区域)。
    • 我看不到额外的可点击区域,请告诉我更多细节,可能是因为你的测试设备,改变你的环境告诉我结果。
    【解决方案2】:

    默认情况下,按钮是可点击的,并且应该在 java 文件中获得点击事件回调,直到您没有将 clickListener 动态设置为 null。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多