>  기사  >  Java  >  Android에서 상하 고정 기능과 중간 영역 슬라이딩 기능을 구현하는 방법

Android에서 상하 고정 기능과 중간 영역 슬라이딩 기능을 구현하는 방법

PHP中文网
PHP中文网원래의
2017-08-26 17:50:573690검색

그런 기능이 필요할 수도 있습니다. 안드로이드 레이아웃은 고정된 상단 및 하단 바, 상단에 메뉴를 구현하고 중간 영역을 터치하여 위아래로 슬라이드할 수 있습니다.

이제 Android 레이아웃 파일에 이 기능을 구현하는 방법을 소개하겠습니다

먼저 eclipse, jdk 및 Android sdk가 설치되어 있는지 확인하세요. 여기서는 하나씩 설명하지 않겠습니다. 아래 코드에서 필수 요소를 드래그하여 생성합니다.

이 코드는 제가 테스트했으며 참조용으로 사용할 수 있습니다.

코드는 다음과 같습니다.

<?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 중국어 웹사이트에서 제공됩니다.

기사 주소: http://www.php.cn/ java-article-377488.html

프로그래밍을 배우려면 PHP 중국어 웹사이트 www.php.cn

을 방문하세요.

위 내용은 Android에서 상하 고정 기능과 중간 영역 슬라이딩 기능을 구현하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.