简体   繁体   中英

Android Mainactivity doesn't show activity_main.xml

After I changed some of my app design at the activity_main.xml and launch the app the MainActivity class design doesn't change. I tried to change the design after I changed the working space from tablet to android phone and the design doesn't fit on the phone the image views are too large and they fill all the phone screen any suggestions how to make it fit within the phone?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_1"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.flagsgame.MainActivity" >

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

    <Button
        android:id="@+id/start_btn"
        android:layout_width="295dp"
        android:layout_height="wrap_content"
        android:text="@string/start_game" />
</LinearLayout>

<Button
    android:id="@+id/reguler"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/linearLayout1"
    android:layout_alignRight="@+id/linearLayout1"
    android:layout_below="@+id/linearLayout1"
    android:text="Classic Mode"
    android:visibility="invisible" />

<Button
    android:id="@+id/time"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/reguler"
    android:layout_alignRight="@+id/reguler"
    android:layout_below="@+id/reguler"
    android:text="Time Attack Maddness" 
    android:visibility="invisible"/>

public class MainActivity extends Activity implements OnClickListener {

private static final String TAG = "Flagss Game" ;//יצירת טאג למשחק לשימוש בםונקציות כמו exception

Button start;
Button time;
Button reguler;
DatabaseHandler db = new DatabaseHandler(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //List<Flagss> arrAdd= new ArrayList<Flagsss>();

    start = (Button)findViewById(R.id.start_btn);
    time = (Button)findViewById(R.id.time);
    reguler = (Button)findViewById(R.id.reguler);
    start.setOnClickListener(this);
    db = new DatabaseHandler(this);

    creat_rows();
}

/*
//קבלת התמונות
private void pic_view(String pic2) {

    // TODO Auto-generated method stub

    //Log.d("Result from pic function " , pic2);
    ImageView imageView = (ImageView)findViewById(R.id.imageView1);
    String uri ="@drawable/";
    uri += pic2;
    int imageResource = getResources().getIdentifier(uri, null, getPackageName());
    Drawable res= getResources().getDrawable(imageResource);
    imageView.setImageDrawable(res);

}*/

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    start.setVisibility(start.INVISIBLE);
    time.setVisibility(time.VISIBLE);
    reguler.setVisibility(reguler.VISIBLE);

    //Intent s = new Intent(this,ClassicMode.class);
    //startActivity(s);

    reguler.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent cm = new Intent(MainActivity.this,ClassicMode.class);
            //Intent c = new Intent(MainActivity.class ,ClassicMode.class);
            startActivity(cm); 
        }
    });

    time.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent tm = new Intent(MainActivity.this,TimeAttack.class);
            startActivity(tm);
            Log.d(TAG, "inside time");
        }
    });
}

Please ensure that you have kept activity_main.xml file in the correct layout directory. It is possible that you might have changed it for another kind of layout. So verify all the activity_main.xml within your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM