简体   繁体   中英

Display Terms and Conditions in Android Studio Activity

i want display terms and conditions in activity. I want to put them in big scrollable textView but the problem is that in my string file i must add Titles, paragraphs, link, with different font, font size, color etc ... How i can do that? At this moment i succeeded to do that with a big scrollView (12000px;.) with multiple textviews and multiple strings? How i can do better. I'm bad in android development..: Here is my xml code :

<?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>

I can not to just put a link instead of all text. I'm obligated to write all in scroll view according to new laws in my country and to make the user accept after he scroll all text .

Better use wrap_content instead of 12000dp at

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

You can format your String in HTML and display it in a WebView like this . You can also upload them to your webpage and show the whole webpage in your application that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM