Android Scrollview in RelativeLayout with ButtonBar

前端 未结 2 1375
陌清茗
陌清茗 2021-01-05 00:50

I\'m trying to implement a login view where several EditTexts and a logo are displayed on the screen with a ButtonBar at the bottom, something like this:

alt text ht

相关标签:
2条回答
  • 2021-01-05 01:21

    If your use case supports hiding of the button bar in landscape orientation you can check Resources.getSystem().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE and set the button bar to View.GONE.

    You also probably need to set android:windowSoftInputMode="adjustResize" on the <activity> in your manifest file. Android will only put it in adjustResize automatically when the root layout is a ScrollView (iirc).

    0 讨论(0)
  • 2021-01-05 01:33

    It turned out that the solution required two steps:

    1. The inability to scroll was a result of the ScrollView being behind the Button Bar. To fix this, I defined the ScrollView below the Button Bar, then used android:layout_above="@id/buttonbar_login" to force the ScrollView to reside entirely above the Button Bar.

    2. Apparently when the onscreen keyboard is opened, if you have a ScrollView it will be resized allowing the Button Bar to float up with the keyboard. To fix this I modified the manifest and added android:windowSoftInputMode="adjustPan" to prevent the ScrollView from resizing.

    0 讨论(0)
提交回复
热议问题