Raf*_*ero 6 android footer android-layout android-softkeyboard android-relativelayout
我一直在寻找解决此问题的方法,但没有找到任何可以解决我的问题的方法。
我使用RelativeLayout作为我的主要布局,我的页脚也是RelativeLayout,我在互联网上找到了这些配置:
android:windowSoftInputMode="adjustPan|adjustResize"
它适用于页脚保持固定但我的滚动不起作用,这是我的主要问题,我能做些什么来解决它?
我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:focusable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:fillViewport="true"
android:isScrollContainer="true"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/ttvp1"
style="@style/ttvPersonalizado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/p1" />
<TextView
android:id="@+id/ttvp2"
style="@style/ttvPersonalizadoDireito"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/p2" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/edtP1"
style="@style/edtPersonalizado"
android:maxLength="5"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_design"
android:ems="10"
android:inputType="numberDecimal" >
</EditText>
<EditText
android:id="@+id/edtP2"
style="@style/edtPersonalizado"
android:maxLength="5"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_design"
android:ems="10"
android:inputType="numberDecimal" />
</LinearLayout>
<TextView
android:id="@+id/ttvpim"
style="@style/ttvPersonalizado"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/pip3" />
<EditText
android:id="@+id/edtPiP3"
style="@style/edtPersonalizado"
android:maxLength="5"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_design"
android:inputType="numberDecimal" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/ttvExame"
style="@style/ttvPersonalizado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="18dp"
android:text="@string/notaExame" />
<CheckBox
android:id="@+id/chkExame"
style="@style/chkPersonalizado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:text="@string/exame" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/edtExame"
style="@style/edtPersonalizado"
android:maxLength="5"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_design"
android:ems="10"
android:enabled="false"
android:inputType="numberDecimal"
android:width="125dp" />
<CheckBox
android:id="@+id/chkPersonalizado"
style="@style/chkPersonalizado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tecnologo" />
</LinearLayout>
<TextView
style="@style/ttvPersonalizado"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/mediaFinal" />
<EditText
android:id="@+id/edtMedia"
style="@style/edtPersonalizado"
android:maxLength="5"
android:layout_height="wrap_content"
android:background="@drawable/edit_text_design"
android:enabled="false"
android:inputType="numberDecimal" />
<TextView
android:id="@+id/ttvStatus"
style="@style/ttvPersonalizado"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/btnGerarMedia"
style="@style/btnMedio"
android:background="@drawable/shapebutton"
android:contentDescription="@string/gerarMedia"
android:src="@drawable/icone_calculadora"
android:text="@string/gerarMedia" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:background="@drawable/background_footer"
android:orientation="vertical" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent" />
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我在 AndroidManifest 中的活动配置:
<activity
android:name="br.com.media_universidades.visao.MediaCalculoActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/umc" android:windowSoftInputMode="adjustPan|adjustResize"/>
Run Code Online (Sandbox Code Playgroud)
先感谢您。
根据您使用的 Android 版本以及您的布局方式,会有不同的解决方案:
\n\n<activity\n android:name="br.com.media_universidades.visao.MediaCalculoActivity"\n android:icon="@drawable/ic_launcher"\n android:label="@string/umc" \n android:windowSoftInputMode="adjustResize"> \nRun Code Online (Sandbox Code Playgroud)\n\n编辑:修复了上面的代码,因为我之前写的答案是使用这个
\n\nandroid:windowSoftInputMode="stateVisible|adjustResize"/>\nRun Code Online (Sandbox Code Playgroud)\n\n但有时你必须使用 onCreate() 方法中的代码来强制它:
\n\ngetWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);\nRun Code Online (Sandbox Code Playgroud)\n\n这是一个修复程序,这是有关此问题的文档。
\n\n\n\n\n该设置必须是下表中列出的值之一,\n 或一个“状态...”值加一个“调整...”值的组合。\n 在任一组中设置多个值 \xe2\x80 \x94 多个“状态...”值,\n 例如 \xe2\x80\x94 具有未定义的结果。各个值由竖线 (|) 分隔\n。例如:
\n
但我没有正确阅读OP问题,他的滚动视图没有移动。这需要将 OnGlobalLayoutListener() 添加到滚动视图。
\n\nfinal View activityRootView = findViewById(R.id.activityRoot);\nactivityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {\n@Override\npublic void onGlobalLayout() {\n Rect r = new Rect();\n //r will be populated with the coordinates of your view that area still visible.\n activityRootView.getWindowVisibleDisplayFrame(r);\n\n int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top);\n if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...\n ... do something here\n }\n }\n}); \nRun Code Online (Sandbox Code Playgroud)\n\n这里有一些很棒的方法。上面的代码来自@Kachi。
\n| 归档时间: |
|
| 查看次数: |
1938 次 |
| 最近记录: |