SQLの窓 イラストAC フリー素材

2016年07月14日

Android の SeekBar を縦方向で使用する設定



XML の画面定義部分の変更だけで対応できました。(setOnSeekBarChangeListener でイベント実装してテスト)
デザイン画面では縦にならず、そもそも、Android Studio のプロパティ一覧に無い android:rotation が必要です。

また、位置調整は、回転した後の位置関係で行います。layout_marginLeft がマイナスなのは、何もしないと右にかなり移動した位置になるからです。
<?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="com.example.lightbox.seekbartest.MainActivity">

    <SeekBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/seekBar"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:rotation="270"
        android:minWidth="100dp"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="-50dp" />
</RelativeLayout>



【Androidの最新記事】
posted by at 2016-07-14 11:23 | Android | このブログの読者になる | 更新情報をチェックする