마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 하단에 메뉴바를 위치 시키려고 하는데요.

0 추천

안녕하세요

안드로이드 웹뷰 하단에 메뉴를 위치 시키려고 합니다.

현재는 이렇게 세팅 했는데요..

MainActivity.this.menuLayout.animate().x(0.0f).y((float) (
                            (MainActivity.this.application.scrHeight
                            - MainActivity.this.application.menuHeaderHeight 
                            - StatusBarHeight)));

화면해상도 높이 - 메뉴 높이 - 상태바 높이                           

이렇게 해서 y좌표로 세팅 하는데,

폰에 따라 상태바 높이를 안빼야 맞는것도 있고

빼야 맞는것도 있고 위치 잡는게 어렵네요.

좋은 방법이 있을까요!?

 

칸지 (120 포인트) 님이 2020년 11월 19일 질문

1개의 답변

0 추천

혹시 코드상에서 위치잡는 이유가 있으신가요?

레이아웃 XML 파일에서
최상위에 RelativeLayout 같은거 두고

layout_alignParentBottom 이거 속성부여하면 안될까요??

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/toolBar">

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="컨텐츠" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/toolBar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="#cccccc"
        android:orientation="horizontal">

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button1" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button2" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button3" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button4" />
    </LinearLayout>
</RelativeLayout>

 

 

 

익명사용자 님이 2020년 11월 20일 답변
...