Tôi đang làm việc trên bố cục nơi tôi đã căn chỉnh cardview
ở giữa màn hình và liên hệ với chúng tôi button
ở cuối màn hình. Bố cục này trông OK khi bàn phím bị đóng.Chế độ xem dưới cùng của phụ huynh ẩn với chế độ xem bố cục chính giữa trên bàn phím mở
Layout.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2">
<ImageView
android:id="@+id/login_image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/login_background" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/grey_background" />
</LinearLayout>
<android.support.v7.widget.CardView
android:id="@+id/media_card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
card_view:cardBackgroundColor="@color/white"
card_view:cardElevation="4dp"
card_view:cardCornerRadius="5dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/logoImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/grey_background"
android:padding="15dp"
android:src="@drawable/logo_login"
/>
<EditText
android:id="@+id/usertext"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_below="@id/logoImageView"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/edittext_background"
android:hint="User ID"
android:maxLength="50"
android:padding="10dp"
android:singleLine="true"
android:textColorHint="@color/hint_text_color"
android:textSize="16sp" />
<FrameLayout
android:id="@+id/passwordLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/usertext"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<EditText
android:id="@+id/passtext"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/edittext_background"
android:fontFamily="sans-serif"
android:hint="@string/password"
android:inputType="textPassword"
android:maxLength="50"
android:padding="10dp"
android:singleLine="true"
android:textColorHint="@color/hint_text_color"
android:textSize="16sp" />
<ImageView
android:id="@+id/passwordeye"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:padding="8dp"
android:layout_marginRight="25dp"
android:src="@drawable/eye_close" />
</FrameLayout>
<LinearLayout
android:id="@+id/termsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/passwordLayout"
android:layout_marginLeft="15dp"
android:layout_marginRight="20dp"
android:layout_marginTop="15dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="@drawable/checkbox_checked" />
<TextView
android:id="@+id/terms_and_cond"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="@color/black"
android:textColorLink="#80000000"
android:textSize="13sp" />
</LinearLayout>
<View
android:id="@+id/lineView"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/termsLayout"
android:layout_marginTop="15dp"
android:background="@color/grey_background" />
<LinearLayout
android:id="@+id/newuser_login_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/dark_grey"
android:layout_below="@id/lineView"
android:orientation="horizontal">
<TextView
android:id="@+id/newUserButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/translucent_round_button"
android:gravity="center"
android:text="New User ?"
android:textColor="@color/grey_text_color"
android:textSize="17sp" />
<TextView
android:id="@+id/loginbutton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bottom_round_button"
android:gravity="center"
android:text="Login"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/contactus_button"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp"
android:background="@drawable/contact_us_selector"
android:drawableLeft="@drawable/contact_us_green"
android:drawablePadding="5dp"
android:gravity="center"
android:padding="8dp"
android:text="Contact Us"
android:textColor="@color/black" />
<TextView
android:id="@+id/textviewone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center"
android:textColor="@color/black"
android:textColorLink="#80000000"
android:textSize="13sp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/snackbarCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</android.support.design.widget.CoordinatorLayout>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/android:progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</FrameLayout>
Câu hỏi: -
Khi bàn phím mở ra sau đó liên hệ với chúng button
và văn bản mà là ở dưới cùng của màn hình ẩn trên đằng sau bố cục trung tâm. Tôi muốn nó không nên được ẩn, trên màn hình bàn phím mở nên được di chuyển và liên hệ với chúng tôi button
nên ở phía dưới.
On mở bàn phím nó trông giống như: -
bạn không có mã trên github hoặc bitbucket để chơi với nó? :-) Chỉ cần hoạt động này với tất cả các tài nguyên. – piotrek1543