2013-10-03 86 views
2

我是新来的这个论坛,也是Android开发的新手。我正在制作我的第一个应用程序(根据J.F. DiMarzio的“实用的Android 4游戏开发”一书),问题非常普遍,正如我看到的 - 启动画面宽度不适合。飞溅图像是9patch格式。它的高度很好,但左侧和右侧总是有一点余量。我如何消除这种情况?Android启动画面宽度

我正在书写代码,因为它是在书中,所以我不知道什么是错的。

Splash image

splashscren.xml:

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

    <ImageView 
     android:id="@+id/splashScreenImage" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:contentDescription="@string/desc" 
     android:src="@drawable/sfstart" > 

    </ImageView> 

    <TextView 
     android:id="@+id/creditsText" 
     android:layout_width="wrap_content" 
     android:layout_height="43dp" 
     android:layout_gravity="center_horizontal|bottom" 
     android:text="@string/bottom" > 

    </TextView> 
</FrameLayout> 

而且MainActivity.java

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //usuwa title bar 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.splashscreen); 
} } 

请帮帮我!

编辑: 我在.xml文件中的ImageView部分找到了相关线程添加android:scaleType =“fitXY”的解决方案。也许这将有助于某人:)

回答

0

我怀疑这是如何创建飞溅图像 - 一些黑色或透明的左侧和右侧。也许你应该在9patch工具中打开spalsh图像并发布它的屏幕截图。

+0

它在9patch中:http://i.imgur.com/VXle1Yp.png – cinek

+0

我无法理解我在链接中看到的确切内容:) - 我期待着其他一些观点。但从我看到的情况来看,我认为9补丁的左右边缘确实存在一些问题,这可以解释您的问题。无论如何,你可以上传原始9patch文件? – trungdinhtrong

+0

http://speedy.sh/rdG8z/sfstart.9.png在这里。这个还有其他的补丁对我来说工作得很好。正如我所说的,scyletype =“fitXY”非常有帮助。 – cinek