2014-06-23 2 views
-1

저는 가로보기를 만들었고 그 안에는 하나의 선형 레이아웃을 만들었습니다. XML 파일 ..horizontalScroll보기가 스크롤하지 않습니다.

<?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" 
    android:background="@drawable/bg" 
    > 


    <ImageView 
     android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
     android:id="@+id/img_view" 
     /> 

    <HorizontalScrollView 
     android:id="@+id/horizontalScrollView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="5dip" 
      android:layout_marginRight="5dip" 
      android:scrollbars="horizontal"> 
    </HorizontalScrollView> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal" > 
    </LinearLayout> 

</LinearLayout> 

나는 horizontalScroll보기에서 가로로 스크롤하지만 내 활동이 단 4 개 버튼과 나던 스크롤을 표시한다 (20 개) 버튼을 만들려고합니다.

내 코드는 안드로이드에서 beginnr

public class NumericPage extends Activity{ 

    private LinearLayout linear_layout; 
    private HorizontalScrollView hzv; 
    Button[] btn = new Button[10]; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
    setContentView(R.layout.numericpage); 
    hzv = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1); 
    linear_layout = (LinearLayout) findViewById(R.id.linearLayout1); 
    for (int j = 0; j < 10; j++) 
    { 
     btn[j] = new Button(this); 
    btn[j].setText("" + j); 
    btn[j].setId(j); 
    btn[j].setWidth(100); 
    btn[j].setHeight(40); 
    linear_layout.addView(btn[j]); 

    } 
     } 
} 

입니다 .. PLZ 도움이! thnx

귀하의 LinearLayout이 당신의 HorizontalScrollView 외부에서 생성

답변

0

<?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" 
android:background="@drawable/bg" 
> 


<ImageView 
    android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
    android:id="@+id/img_view" 
    /> 

<HorizontalScrollView 
    android:id="@+id/horizontalScrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="5dip" 
     android:layout_marginRight="5dip" 
     android:scrollbars="horizontal"> 

    <LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" /> 

</HorizontalScrollView> 


</LinearLayout> 
+0

감사합니다 같은 레이아웃을 수정 ... 어리석은 실수 : P – user3768423

관련 문제