ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文

  メンテナンス 前画面に戻る

対象スレッド 件名: 画面を作成する
名前: lightbox
処理選択
パスワード

件名 画面を作成する
名前 lightbox
コメント
まず、インターネットからテキストデータを取得して、TextView に表示する為の画面を作成します

https://lh3.googleusercontent.com/-fVSd5lSBWd4/Vy8YUAAUuJI/AAAAAAAAeX4/fE24bNRWUP4M5I-Y4vF3WIgRLnk_cNKQwCCo/s400/_img.png

▼ activity_main.xml
@DIV
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="lightbox.may.toolstest.MainActivity">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:id="@+id/linearLayout">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button1"
            android:id="@+id/button"
            android:layout_weight="1"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button2"
            android:id="@+id/button2"
            android:layout_weight="1"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button3"
            android:id="@+id/button3"
            android:layout_weight="1"/>

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/scrollView"
        android:layout_below="@+id/linearLayout"
        android:layout_alignParentStart="true"
        android:layout_marginTop="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/textView"/>
    </ScrollView>

</RelativeLayout>
@END

@SHOW
ボタンを横に3つ均等に並べる為に LinearLayout(horizontal) を使用しています。
※ 均等に配置しているのは android:layout_weight="1" です。

ScrollView は、RelativeLayout 内で、LinearLayout より、10dp 下に配置して、残りのスペースを全て使用しています ※ スペース一杯は android:layout_width="match_parent" と android:layout_height="match_parent"
@END