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

안드로이드 버튼 관련(커스텀 키보드..)

0 추천
안녕하세요 한 초보 개발자 인데요.

커스텀 키보드를 만들고 있는데..

간단하게 버튼으로 구성해서 문자 버튼을 클릭시 입력이 되게 하는 것..

키보드 모양이라 첫줄 10개, 둘째줄 10개, 셋째줄 9개, 넷째줄 5개의 버튼으로 구성되는데요..

우선 첫줄 버튼을 10개를 넣으면.. 8개의 버튼은 나오는데 나머지 2개의 버튼은 화면에서 짤리네요..

weight를 줘봐도 그렇고.. 어떻게 레이아웃을 잡아야 버튼을이 안 짤리고 잘 구성될까요..?

그리고 Shift버튼이나 Del버튼도 일반 버튼들과 사이즈가 조금 더 커야되는데.. 이게 커지면 위에 버튼들도

사이즈가 제각각이 되더라구요..

아직 초보라 도움 좀 부탁드리겠습니다..ㅠ
익명사용자 님이 2013년 8월 27일 질문

1개의 답변

0 추천

각 버튼에 weight 를 1씩 주면 길이에 따라 균등 하게 나올 것같습니다.

또는 아래와 같이 할 수 도 있습니다. 합이 1이 되게 하면 각각의 길이 조정도 가능합니다.

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

    <Button
        android:id="@+id/list_complex_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:text="2"
 />

    <Button
        
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_weight="0.1"
        android:text="2"
 />
    <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
    

        <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
            <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
                <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
                    <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
                        <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
                            <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
                                <Button
        
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:layout_width="wrap_content"
        android:text="2"
 />
</LinearLayout>

 

웅바라지 (4,780 포인트) 님이 2013년 8월 27일 답변
아까 버튼때문에 질문했던 사람인데요..
웅바라지님 덕분에
layout_weight로 해결은 했는데
버튼의 사이즈가 다르면 버튼 크기가 뒤죽박죽 되는데.. 이 문제는 어떻게 해결해야될까요..?쉬프트 버튼은 이미지버튼이라 일반 버튼들보다 조금 더 큰데 이 버튼때문에 위에 있는 버튼까지 늘어나게 되네요..ㅠ
리니어 레이아웃 안에 각 버튼의 갯수만큼 리니어 레이아웃을 만드시구요
그 각가의 레이아웃안에 버튼을 집어너으시면 될꺼에요
...