android 工作室按钮 textwiew 手势
android studio button textwiew gestures
它们在不停地移动,我该如何固定它们
我做了一个随机应用程序,但是当你按下按钮时,文本视图和按钮不断变化。我怎样才能防止这种情况发生?如下图
enter image description here
enter image description here
enter image description here
我在这些中使用的代码
<TextView
android:id="@+id/tw1"
android:textSize="15dp"
android:text=""
android:gravity="center"
android:textIsSelectable="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn1"
android:text="random"
android:textSize="50dp"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
问题是您使用的是 LinearLayout 并且其子项在默认情况下是水平布局的。根据 TextView 中文本的长度,'pushing' Button 向右(水平)。如果您想更改此行为,请考虑使用不同的布局或更改当前 LinearLayout 的方向,方法是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
LinearLayout children orientation
它们在不停地移动,我该如何固定它们
我做了一个随机应用程序,但是当你按下按钮时,文本视图和按钮不断变化。我怎样才能防止这种情况发生?如下图
enter image description here
enter image description here
enter image description here
我在这些中使用的代码
<TextView
android:id="@+id/tw1"
android:textSize="15dp"
android:text=""
android:gravity="center"
android:textIsSelectable="true"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn1"
android:text="random"
android:textSize="50dp"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
问题是您使用的是 LinearLayout 并且其子项在默认情况下是水平布局的。根据 TextView 中文本的长度,'pushing' Button 向右(水平)。如果您想更改此行为,请考虑使用不同的布局或更改当前 LinearLayout 的方向,方法是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
LinearLayout children orientation