我有一个主要活动,我在Android Studio中使用XML创建布局,并根据需要正确设置宽度和高度,但在我的设备上执行代码后,我得到了相同布局的不同视图。
而且我想在我的键盘处于活动状态时向上滚动我的布局但在添加android:windowSoftInputMode="adjustResize"
后没有帮助我。
<RelativeLayout
android:id="@+id/lay_zcrt_img"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/splash1">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp"
android:background="@drawable/login_layout_border">
<ImageView
android:layout_width="250dp"
android:layout_height="120dp"
android:layout_margin="4dp"
android:src="@drawable/login_logo" />
</RelativeLayout>
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginLeft="35dp"
android:layout_marginTop="230dp"
android:layout_marginRight="35dp"
android:background="@drawable/lay_login_border"
app:cardCornerRadius="14dp">
<RelativeLayout
android:layout_width="350dp"
android:layout_height="300dp"
android:layout_gravity="center">
<TextView
android:id="@+id/txt_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="Login"
android:textColor="#000"
android:textSize="25dp" />
<EditText
android:id="@+id/edt_phone_number"
android:layout_width="300dp"
android:layout_height="65dp"
android:layout_marginTop="55dp"
android:layout_below="@+id/txt_title"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal|center_vertical"
android:hint="Mobile"
android:inputType="number"
android:maxLength="10" />
<Button
android:id="@+id/btn_login"
android:layout_width="300dp"
android:layout_height="55dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginBottom="8dp"
android:background="@drawable/btn_corner"
android:gravity="center_horizontal|center_vertical"
android:text="Submit"
android:textAlignment="center"
android:textColor="#fff" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
在这里,您可以从图像中看到我在社区中搜索了很多但没有得到任何与此相关的文章。
将android:layout_width
设置为match_parent
,然后添加marginStart和marginEnd