-1

I'm trying to add scroll down to one of my relative layout. the problem is that all of the text inside the scroll down disappear (from text view 4 till the end - notes0-nite4). If I put the code at the beginning of the main activity xml its working fine- however I would like to use the scroll down only in one layout. I added a picture of my code

I used the links below but it did not help

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
michal
  • 17
  • 6

1 Answers1

0

You haven't mentioned an orientation for your LinearLayout

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

It's horizontal by default so what's happening is that your first TextView howToPlayText takes up the entire width and then the rest aren't visible anymore.

n_r
  • 589
  • 7
  • 17