Выровняйте текст друг под другом в макете - PullRequest
0 голосов
/ 10 октября 2018

Я создал экран информации о платеже, но хотел бы настроить его так, чтобы он выглядел как image ниже.Я добавил ниже мой попытался код.Как мне это сделать?Любая помощь будет принята с благодарностью.Я хотел бы знать, как разбить layout на 3 секции и иметь buttons как image.Кроме того, как бы я выровнял мои text, чтобы быть под друг друга?

Изображение того, что я хотел бы достичь

image1

Код ниже

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/colorPrimary"
    android:layout_gravity="center">

   <LinearLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center"
       android:orientation="vertical">


       <ImageView
           android:layout_gravity="center"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/solver"/>

       <View
           android:layout_marginTop="5dp"
           android:layout_width="match_parent"
           android:layout_height="1dp"
           android:background="@android:color/darker_gray"/>

       <LinearLayout
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:orientation="horizontal"
           android:layout_gravity="center">

           <LinearLayout
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:orientation="vertical">

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="Record phone calls"
                   android:textColor="@color/colorWhite"
                   android:layout_gravity="center"
                   android:textSize="18sp"/>

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="Know who viewed your profile"
                   android:textColor="@color/colorWhite"
                   android:layout_gravity="center"
                   android:textSize="18sp"/>

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="Option to view profiles privately"
                   android:textColor="@color/colorWhite"
                   android:layout_gravity="center"
                   android:textSize="18sp"/>

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="Get the Premium badge on your profile"
                   android:textColor="@color/colorWhite"
                   android:layout_gravity="center"
                   android:textSize="18sp"/>

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="30 contact requests a month"
                   android:layout_gravity="center"
                   android:textColor="@color/colorWhite"
                   android:textSize="18sp"/>

               <TextView
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:text="No ads"
                   android:layout_gravity="center"
                   android:textColor="@color/colorWhite"
                   android:textSize="18sp"/>

           </LinearLayout>

       </LinearLayout>

       <Button
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Monthly Premium      R19,19"/>

       <Button
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="Yearly Premium        R179,99"/>

   </LinearLayout>

</ScrollView>

1 Ответ

0 голосов
/ 11 октября 2018

Не используйте scrollView.Используйте вертикальный LinearLayout и дайте своим детям подходящие веса. Примерно так:

<LinearLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:layout_gravity="center"
       android:orientation="vertical">
<ImageView android:layout_width="match_parent"
       android:layout_height="match_parent"
android:weight="1.25">

<LinearLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:layout_gravity="center"
    android:weight="1"
       android:orientation="vertical">

</LinearLayout>

</LinearLayout>

А для транспаренса используйте этот стиль для своей активности в манифесте

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">#66000000</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:windowFullscreen">true</item>
</style>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...