ホームページ  >  記事  >  Java  >  Androidで上下固定と中央部分のスライド機能を実装する方法

Androidで上下固定と中央部分のスライド機能を実装する方法

PHP中文网
PHP中文网オリジナル
2017-08-26 17:50:573690ブラウズ

そのような機能が必要になる場合があります。Android のレイアウトでは、上部と下部の固定ストリップが実装されており、上部にメニューがあり、中央の領域をタッチして上下にスライドできます。

この機能を Android レイアウト ファイルに実装する方法を紹介します

まず、Eclipse、jdk、Android sdk がインストールされていることを確認してください。ここでは 1 つずつ説明しません。 Android 仮想マシンを作成して作成します。以下のコードに必要な要素をドラッグします。

このコードは私によってテストされており、参照可能です

コードは次のとおりです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android";
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true" >
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>
    <ListView
            android:id="@+id/listView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/bottom"
            android:layout_below="@id/linearLayout1"
           >
        </ListView>
        <LinearLayout
            android:id="@+id/bottom"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true" >
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Button" />
        </LinearLayout>
    
    </RelativeLayout>
  
  </LinearLayout>

この記事は PHP 中国語 Web サイトから提供されています

記事のアドレス: http://www.php.cn/ java-article-377488.html

プログラミングを学ぶには、PHP 中国語 Web サイト www.php.cn にアクセスしてください

以上がAndroidで上下固定と中央部分のスライド機能を実装する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。