I can't see the buttons

cidelabcidelab Member ✭✭
edited June 2018 in Xamarin.Android

Hello to all,

In the latest visual studio 2017 community with the latest Xamarin,
I dragged 2 buttons and a textview into the phone canvas (I don't know how to call it. Emulate the phone during the design process)
But I only can see the text view in the Design label, but in the Source, I can see the buttons and the text view.

can you help me?
What I'm missing?

Any clue, would be very helpful
thanks in advance
Carlos.

Best Answer

  • cidelabcidelab ✭✭
    Accepted Answer

    Resolved,
    I did not use any layout so the textview was over the buttons.
    I had to add a vertical layout and all went ok.

    thanks
    Carlos.

Answers

  • DimChrisDimChris USMember ✭✭✭

    Did you set the content view in main activity?

       base.OnCreate(savedInstanceState);
    
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
    
  • cidelabcidelab Member ✭✭
    edited June 2018

    Thank you DimChris,
    Yes I have the main activity like this:

    namespace test_2
    {
    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
    protected override void OnCreate(Bundle savedInstanceState)
    {
    base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            System.DateTime timeNow = System.DateTime.Now;
            string time = timeNow.ToString();
    
        }
    }
    

    }

    In the Source I have this:

    <TextView
        android:text="0"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="20dp"
        android:textSize="50sp" />
    <Button
        android:text="Increase"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/button2" />
    <Button
        android:text="Decrease"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/button1" />
    

  • cidelabcidelab Member ✭✭
    Accepted Answer

    Resolved,
    I did not use any layout so the textview was over the buttons.
    I had to add a vertical layout and all went ok.

    thanks
    Carlos.

Sign In or Register to comment.