我有两个活动A和B.当我点击A中的按钮时会显示B.当我点击B中的按钮时它返回到A.我在finish()方法之后设置了overridePendingTransition方法.它工作正常.但是如果当前活动是B.那么我单击设备中的默认后退按钮.它显示了从右到左的过渡以显示活动A.
我怎么能听到设备上的默认返回键?
编辑:
Log.v(TAG, "back pressed");
finish();
overridePendingTransition(R.anim.slide_top_to_bottom, R.anim.hold);
Run Code Online (Sandbox Code Playgroud) 我有一个活动,其中有一个EditText,并在输入键搜索结果显示,所以我只想关闭键盘,当搜索结果即将显示,以防止用户必须这样做.但是,如果用户想要优化他的搜索,键盘应该打开,如果他再次点击EditText.
这比我想象的要困难得多,我一直在搜索并尝试了一些大多数甚至不关闭我的HTC键盘的东西,一种方法,其中InputType设置为INPUT_NULL关闭键盘,但之后不打开.
有关如何做到这一点的任何建议?
这是我的屏幕,键盘后面隐藏着一个按钮.
我想要这样,但可滚动. -
每当键盘打开时,我想让它看起来和图像一样.但是,要使其可滚动,以便用户可以滚动以查看屏幕的底部(包括按钮),即使键盘处于打开状态.
我试过了 -
android:windowSoftInputMode="adjustResize"
Run Code Online (Sandbox Code Playgroud)
但是,只要键盘打开,这就会将底部向上移动.
如在这张图片中 -
我不想要这个 - (Create Account当键盘打开时按钮向上移动)
滚动后必须显示CREATE ACCOUNT按钮.
这是布局 -
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/root_layout"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="10"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:orientation="vertical"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<EditText
android:id="@+id/et_username_or_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/et_hint_username_or_email"
android:inputType="textEmailAddress"
android:singleLine="true"
/>
<EditText
android:id="@+id/et_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/et_hint_password"
android:password="true"
android:singleLine="true"
/>
<Button
android:id="@+id/btn_sign_in"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/btn_sign_in"
android:background="@color/lighter_orange"
android:textColor="@android:color/white"/>
<TextView
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/or"
android:gravity="center_horizontal" …Run Code Online (Sandbox Code Playgroud) 我有一些视图(名称,电子邮件,密码,注册按钮):
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ViewFlipper
android:id="@+id/viewflipper"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
//Layouts
</ViewFlipper>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
当我关注edittext字段时,键盘出现并覆盖视图上的下部字段.所以当键盘存在时我看不到它们.我想知道如何使视图可滚动,以便我可以看到较低的字段.此外,如何使视图自动滚动以使聚焦的字段可见.
我最近决定将我的应用程序移动到使用新的支持设计库,最近发现了一个非常讨厌的bug.
假设我有一个CoordinatorLayout托管AppBarLayout和任何可滚动的视图,无论是ViewPager,NestedScrollView,还是具有所需滚动行为的RecyclerView; 选择显示一个显示键盘的对话框片段会导致AppBarLayout与滚动视图断开连接,并且它们不再滚动在一起.
此外,滚动视图被强制调整到底部屏幕的一半,而AppBar布局占据了上半部分,尽管它不需要它.
这个bug的视频在这里: Youtube Link
编辑:
将Activity中键盘的softInputMode设置为"adjustPan"可以解决问题.显然,CoordinatorLayout不喜欢通过键盘动态调整大小.
违规的XML看起来像这样,但我有多个XML变体表现出这种行为,其中的共同元素都是他们使用的是CollapsingToolbarLayout:
<android.support.design.widget.CoordinatorLayout 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"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="192dp"
android:background="@color/transparent">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="144dp"
android:elevation="4dp"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginBottom="@dimen/quadruple_margin"
app:layout_collapseParallaxMultiplier="0.7"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@color/primary"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/ranking_background" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_gravity="bottom"
android:background="@color/black_40" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_picture"
android:layout_width="@dimen/double_margin"
android:layout_height="@dimen/double_margin"
android:layout_alignBottom="@+id/text"
android:layout_marginLeft="@dimen/double_margin"
android:layout_marginStart="@dimen/double_margin"
android:src="@drawable/image_placeholder"
android:visibility="gone" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:layout_marginLeft="@dimen/single_margin"
android:layout_marginStart="@dimen/single_margin"
android:layout_marginTop="@dimen/quadruple_margin"
android:layout_toRightOf="@+id/profile_picture"
android:text="@string/my_places_for"
android:textColor="@color/white"
android:textSize="20sp"
android:visibility="gone" …Run Code Online (Sandbox Code Playgroud) android android-keypad android-dialogfragment android-support-library android-coordinatorlayout
我有一个带有表单的活动.因为表单很长,所以我使用了scrollview.
问题是当键盘启动时,scrollview不会改变.键盘与scrollview的最后一部分重叠.
如何确保键盘位于scrollview下方并调整scrollview以适应其上方的空间?
同时,有没有办法确保键盘上的"上一个"和"下一个"按钮也在键盘中?
在我的片段中,我在scrollview中有一个editText,当我点击它时,我将它设置为打开如下:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)
它从第一次打开时工作正常,但当我关闭键盘并再次打开它时,它与editText重叠,如何将editText设置为始终在SOFT_INPUT_ADJUST_PAN模式下打开?
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/alabaster">
<TextView
android:id="@+id/semconexao"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Verifique sua conexão com a internet"
android:gravity="center"
android:layout_marginTop="10dp"
android:visibility="gone"/>
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/footer">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="visible">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imageInst"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:visibility="visible" />
<com.retornar.utils.CircledNetworkImageView
android:id="@+id/thumbnail"
android:layout_width="@dimen/logo_maior"
android:layout_height="@dimen/logo_maior"
android:layout_marginLeft="20dp"
android:layout_marginTop="100dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop">
</com.retornar.utils.CircledNetworkImageView>
<ImageView
android:id="@+id/more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_amp"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
<TextView
android:id="@+id/retornarTitulo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/imageInst"
android:layout_marginTop="20dp"
android:gravity="center"
android:padding="10dp"
android:text="@string/retornarTitulo"
android:textColor="@color/armadillo"
android:textSize="@dimen/text2" /> …Run Code Online (Sandbox Code Playgroud) 我有一个EditText组件,当然,如果你点击它,会显示Android键盘,允许用户输入文本.据我所知,所有Android软件键盘都有(至少)字母模式(ABC)和符号模式(?123).他们的默认视图是字母模式.
现在,当EditText单击组件时显示键盘时,我希望默认显示符号模式.用户仍然可以切换到字母模式.

有没有办法实现这一目标?如果有,怎么样?
android android-keypad android-softkeyboard android-inputtype
我正在开发一个Android应用程序,我愿意从用户那里获得输入.我为它创建了一个布局,它有一个滚动视图作为根视图和相对布局,因为它的孩子所有其他布局都在这个相对布局中.但是当编辑文本位于屏幕的底部并且用户点击它以带来键盘时,它会在编辑文本和键盘之间显示一些空白框,然后如果用户输入任何单词,它就不会显示在编辑文本中.但是如果编辑文本高于屏幕的一半大小,那么它可以正常工作.通过查看下面的图像,您可以更清楚地了解到


有人遇到过这种问题吗?请帮忙!!!