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

아래의 사진과 같이.. 만들어야하는데 왜 이미지가안내려올까요 ㅠ

+1 추천

 

안녕하세요.

탭호스트로 첫번째 탭의 이미지를 만드는 도중에, 잘 안되는 부분이 있어서 글을 올렸습니다.

첫번째 탭 아래의 배경이 아래의 바로 두번째 이미지의 사진이 되어야 합니다.

그런데, 버튼 같은 경우에는, 제가 직접 만든 다음에, 클릭이벤트를 통하게 만들어야해서

결론적으로는 버튼을 제외한 첫번째 사진만 컨텐츠부분에 넣은 다음에, 그 아래에 바로 버튼을 below에 위치시켜서 만들려고 했는데 생각했던것처럼 쉽게 해결이 되지가 않습니다.

일단, 사진이 먼저 예쁘게 배경화면에서 자리를 잡고, 그 이미지 아래에, 버튼을 삽입하려고 했으나

3번째 이미지와 같이, match를 주었는데도, 저렇게 애매한 위치에 자리잡고 있는 바람에.. 어떻게 해야할지

참 막막하네요..

어떻게 해야, 2번째 이미지같이 탭의 컨텐츠에서 예쁘게 자리잡고, 그 아래에 버튼을 삽입할수 있을까요 ㅠ

코드에 어느 부분이 잘못되었는지 잘 모르겠습니다..

8000자 제한이 있어서 코드를 아래의 답변부분에 적어보았습니다.

 

<Data_and_Seat 자바파일 >

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.Toast;

public class Date_and_Seat extends AppCompatActivity {

    ImageView Before_Date_and_Seat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_date_and__seat);

        TabHost tab_host = (TabHost) findViewById(R.id.tabhost);
                tab_host.setup();

                TabHost.TabSpec ts1 = tab_host.newTabSpec("tab1");
                ts1.setIndicator("tab1");
                ts1.setContent(R.id.tab1);
                tab_host.addTab(ts1);

                TabHost.TabSpec ts2 = tab_host.newTabSpec("tab2");
                ts2.setIndicator("tab2");
                ts2.setContent(R.id.tab2);
                tab_host.addTab(ts2);

                 TabHost.TabSpec ts3 = tab_host.newTabSpec("tab2");
                 ts3.setIndicator("tab2");
                 ts3.setContent(R.id.tab3);
                 tab_host.addTab(ts3);

                tab_host.setCurrentTab(0);


        Before_Date_and_Seat = (ImageView) findViewById(R.id.Before_Date_and_Seat_Image);
        Before_Date_and_Seat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

           }
}

 

 

 

공산당 (1,960 포인트) 님이 2016년 10월 31일 질문
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_date_and__seat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="ex.real_project.Date_and_Seat">

    <RelativeLayout
        android:id="@+id/Date_and_Seat_Toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/Before_Date_and_Seat_Image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="3dp"
        android:layout_marginLeft="3dp"
        android:background="@drawable/before_image" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="예매"
        android:textSize="30dp"
        android:textStyle="bold"
        android:layout_marginTop="10dp"
        android:layout_centerHorizontal="true" />

    </RelativeLayout>


            <TabHost
            android:id="@+id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
                >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                    <TabWidget

                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" >

                     </TabWidget>

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent" >

                    <ScrollView
                        android:id="@+id/tab1"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent" >

                        <TableRow
                            android:id="@+id/tableRow1"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent">

                            <TextView
                                android:id="@+id/textView1"
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:background="@drawable/first_tab_image"
                                android:textAppearance="?android:attr/textAppearanceMedium" />

                        </TableRow>

                    </ScrollView>

                    <ScrollView
                        android:id="@+id/tab2"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                        <TextView
                                android:id="@+id/textView2"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="test2"
                                android:textAppearance="?android:attr/textAppearanceMedium" />
                    </ScrollView>


                    <ScrollView
                        android:id="@+id/tab3"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                        <TextView
                            android:id="@+id/textView3"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="test3"
                            android:textAppearance="?android:attr/textAppearanceMedium" />
                    </ScrollView>





                </FrameLayout>
            </LinearLayout>
    </TabHost>

</LinearLayout>

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...