Android的布局图毛刺 [英] Android layout drawing glitch

查看:174
本文介绍了Android的布局图毛刺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个机器人比赛,我已经创造了它有这个XML主菜单的布局:

I am writing an android game, I have created a layout for the main menu which has this XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/tvStats"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="fill_horizontal"
        android:gravity="fill_horizontal" >

        <Button
            android:id="@+id/btnStartSurvive"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:gravity="center_vertical|center_horizontal"
            android:text="Start Survival Mode" />

        <Button
            android:id="@+id/btnStartChall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="fill_horizontal"
            android:text="Start Callenge Mode" />

    </LinearLayout>

</LinearLayout>

布局显示使用该活动在屏幕上:

The layout is shown on the screen using this activity:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.*;

public class MainActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Get rid of the stuff around the edges
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        //show layout
        setContentView(R.layout.main_menu);
        Button btnStart = (Button)findViewById(R.id.btnStartSurvive);
        btnStart.setOnClickListener(oclStart);
    }

    private OnClickListener oclStart = new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(MainActivity.this, GameActivity.class);
            intent.putExtra("gametype", 'S');
            startActivity(intent);  
        }
    };

}

在我的手机(Android版4.2.2)上运行此我得到的东西看起来是这样的:

When I run this on my phone (Android 4.2.2) I get something that looks like this:

点击未使用按钮使得它看起来是这样的:

Clicking the unused button makes it look like this:

当我在我的旧的平板电脑(Android 2.2的)运行此我得到了我的预期:

When I run this on my older tablet (Android 2.2) I get what I expected:

这是一款Android漏洞?我如何围绕它得到什么?

Is this an Android Bug? How do I get around it?

抑或是我的错?如何解决呢?

Or is it my fault? How do I fix it?

推荐答案

我已经成功地复制了同样的结果,在银河S4,运行4.2.2。
按钮似乎没有工作那么好因为某些原因。

I've managed to duplicate the same results, on a Galaxy s4, running 4.2.2. Buttons don't seem to work all that well for some reason.

你有没有试图改变主题?有时候主题会搞乱布局。

Have you tried changing the theme? Sometimes the theme will mess up a layout.

这篇关于Android的布局图毛刺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆