私の相対レイアウトの1つにスクロールを追加しようとしています。問題は、スクロールダウン内のすべてのテキストが消えることです(テキストビュー4から最後まで - notes0-nite4)。主なアクティビティXMLの先頭にコードを置くと、うまく動作しますが、スクロールを1つのレイアウトでのみ使用したいと考えています。 私は以下のリンクを使用しますが、それはあなたがあなたのための方向性を言及していないAndroidスクロールが機能しない
How to make my layout able to scroll down? Why My ScrollView not working Properly?
<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
リンクが切れています。 –
いくつかの便利なコードを提供します –
私の質問を更新しました – michal