2017-07-29 5 views
-1

私の相対レイアウトの1つにスクロールを追加しようとしています。問題は、スクロールダウン内のすべてのテキストが消えることです(テキストビュー4から最後まで - notes0-nite4)。主なアクティビティXMLの先頭にコードを置くと、うまく動作しますが、スクロールを1つのレイアウトでのみ使用したいと考えています。 私は以下のリンクを使用しますが、それはあなたがあなたのための方向性を言及していないAndroidスクロールが機能しない

How to make my layout able to scroll down? Why My ScrollView not working Properly?

enter image description here

<ScrollView 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:id="@+id/scroll" 
    android:orientation="vertical" 
    android:visibility="invisible" 
    > 

<LinearLayout 
    android:id="@+id/howToPlayLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    > 



    <TextView 
     android:id="@+id/howToPlayText" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:gravity="center_horizontal" 
     android:text="@string/how_to_play" 
     android:textColor="@android:color/black" 
     android:textSize="30sp" /> 

    <TextView 
     android:id="@+id/textView4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="4dp" 
     android:text="@string/insert_each_letter_in_the_right_cell_so_when_the_puzzle_is_completed_every_row_and_column_contains_a_real_4_letters_word_4_words_horizontally_and_4_words_vertically_top_to_bottom" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="17sp" 
     android:textStyle="italic" /> 



    <TextView 
     android:id="@+id/textView6" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="10dp" 
     android:text="@string/share_a_freind_button_is_used_to_get_friend_s_help_via_whatsapp_facebook_twitter" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="17sp" 
     android:textStyle="italic" /> 

    <TextView 
     android:id="@+id/textView7" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="10dp" 
     android:text="@string/lamp_button_can_give_you_a_free_hint_after_watching_a_video_ad" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="17sp" 
     android:textStyle="italic" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="10dp" 
     android:text="@string/x_button_is_used_in_order_to_delete_a_letter_which_you_located_wrongly_in_the_puzzle" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="17sp" 
     android:textStyle="italic" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="20dp" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="10dp" 
     android:text="@string/the_puzzle_may_also_contains_names" 
     android:textColor="@android:color/holo_blue_dark" 
     android:textSize="17sp" 
     android:textStyle="italic" 
     tools:textStyle="italic" /> 

    <Button 
     android:id="@+id/button37" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginRight="40dp" 
     android:layout_marginTop="10dp" 
     android:background="@android:color/holo_blue_dark" 
     android:onClick="backToGame" 
     android:text="@string/back_to_game1" 
     android:textColor="@android:color/white" 
     android:textSize="17sp" /> 

    <Button 
     android:id="@+id/button39" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:layout_marginLeft="40dp" 
     android:layout_marginRight="40dp" 
     android:layout_marginTop="10dp" 
     android:background="@android:color/holo_blue_dark" 
     android:onClick="backToMenu" 
     android:text="@string/back_to_menu1" 
     android:textColor="@android:color/white" 
     android:textSize="17sp" /> 

    <!-- End How to play layout--> 


</LinearLayout> 
</ScrollView> 




@Override 
public boolean onCreateOptionsMenu(Menu menu) { 

    MenuInflater menuInflater=getMenuInflater(); 
    menuInflater.inflate(R.menu.main_menu,menu); 

    return super.onCreateOptionsMenu(menu); 
} // End onCreateOptionsMenu 



@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    super.onOptionsItemSelected(item); 

    switch (item.getItemId()){ 

     case R.id.howToPlay: 
      ScrollView mScrollView=(ScrollView)findViewById(R.id.scroll); 
      mScrollView.setVisibility(View.VISIBLE); 

      howToPlayLayout.setVisibility(LinearLayout.VISIBLE); 
      note0.setVisibility(View.VISIBLE); 
      note1.setVisibility(View.VISIBLE); 
      note2.setVisibility(View.VISIBLE); 
      note3.setVisibility(View.VISIBLE); 
      note4.setVisibility(View.VISIBLE); 
      titleHowToPlay.setVisibility(View.VISIBLE); 


enter code here 
+0

リンクが切れています。 –

+0

いくつかの便利なコードを提供します –

+0

私の質問を更新しました – michal

答えて

0

を助けにはならなかった私のコード

の写真を追加しましたLinearLayout

<LinearLayout 
    android:id="@+id/howToPlayLayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"    //Here 
    > 

デフォルトでは、の水平です。そのため、最初のTextView howToPlayTextは幅全体を占め、残りはもう表示されなくなりました。

+0

私は試してみましたが、うまくいきませんでした。私はスクロールタイトルの後にしたい、私のアプリは@ smash – michal

+0

、クラッシュするあなたのログを投稿しています。 – Kiya

関連する問題