【问题标题】:Display Terms and Conditions in Android Studio Activity在 Android Studio Activity 中显示条款和条件
【发布时间】:2021-05-16 13:14:41
【问题描述】:

我想在活动中显示条款和条件。我想把它们放在 big scrollable textView 但问题是在我的字符串文件中我必须添加标题、段落、链接、不同的字体、字体大小、颜色等 ......我怎么能做到这一点? 此刻,我成功地使用带有多个文本视图和多个字符串的大滚动视图(12000 像素!;)做到了这一点。我怎样才能做得更好?我在android开发方面很糟糕...... 这是我的 xml 代码:

<?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"
    tools:context=".controller.CguActivity"
    android:background="@color/white">

    <RelativeLayout
        android:id="@+id/relativeTerms"
        android:layout_width="match_parent"
        android:layout_height="12000dp">


        <TextView //TITLE IN BOLD ITALIC 19SP
            android:id="@+id/termsTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginBottom="10dp"
            android:text="@string/title_terms"
            android:gravity="center"
            android:fontFamily="@font/custom_font_bold_italic"
            android:textColor="@color/lightBlack"
            android:textSize="19sp"/>

        <TextView // ARTICLE TITLE IN BOLD 17SP
            android:id="@+id/article1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/termsTitle"
            android:layout_marginTop="30dp"
            android:fontFamily="@font/custom_font_bold"
            android:text="@string/article1_terms"
            android:textColor="@color/lightBlack"
            android:textSize="17sp" />

       <TextView // PARAGRPAHE 1 IN REGULAR 15 SP
            android:id="@+id/para1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/article1"
            android:layout_marginTop="10dp"
            android:fontFamily="@font/custom_font_regular"
            android:text="@string/para1"
            android:textColor="@color/lightBlack"
            android:textSize="15sp" />

       ... // LOT OF ARTICLE TITLES, SUBTITLES AND PARAGRAPHS
    
   </RelativeLayout>
</ScrollView>

我不能只放一个链接而不是所有文本。 我有义务根据我所在国家/地区的新法律在滚动视图中书写所有内容,并让用户在滚动所有文本后接受

【问题讨论】:

    标签: java android xml kotlin


    【解决方案1】:

    最好使用wrap_content 而不是12000dp at

    <RelativeLayout
        android:id="@+id/relativeTerms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    

    您可以在 HTML 中格式化您的字符串并将其显示在 WebView 中,例如 this。 您还可以将它们上传到您的网页,并以这种方式在您的应用程序中显示整个网页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 2015-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多