首先要说的是我是新来的android开发,但我有经验与发展中的c + +,python,php & mysql以及HTML和CSS当然。Android背景图像裁剪
我正在玩基于在线文本的mmorpg。最近,他们增加了使用API密钥的能力,以便访问个人帐户信息(例如查看您的能量,冷却时间等)。所以我想出了一个想法,我会制作像“watch”这样的应用程序,这会在例如推送通知时推送给您。你的冷却时间结束了。所以你唯一需要做的就是输入你的API密钥。如果我想让这个应用程序工作(没有时间表,因为首先会用于我的使用),我当然会与其他用户分享。总之,解决问题!
我在寻找类似的问题谷歌和stackoverflow,唯一我偶然发现有用的是这样的:Android crop background,但是这不是退出解决我的问题。
我有一个大小496x60的图像。如果设备宽度小于图像宽度,并且要有100%的高度,我希望将此图像水平裁剪。这是我正在使用的图像(从官方PC应用程序,但没有应用程序的Android手机):logotorn1(链接在最后)
现在我到目前为止所做的(我有按钮,输入密钥框,和一些文本,但删除它们,所以它只是这个atm),这是(我在我的华为y330手机上运行的应用程序):1
该图像似乎有点挤压,所以我决定手动裁剪第一并用当前图像替换它。这是第二图像:logotorn2
这是结果:2
这是我到目前为止的代码:(?)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" tools:context=".MainActivity"
android:foregroundGravity="top"
android:gravity="top"
android:background="@drawable/bgimg">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/imageView"
android:background="@drawable/lel"
android:layout_gravity="left|top"
android:scaleType="centerCrop"/>
</FrameLayout>
</RelativeLayout>
MainActivity.java代码是不相关的ATM,所以我不会发表它。
所以,问题是,我忽略了什么,或者我做错了什么?
在此先感谢您提供的任何帮助。
Hector
P.S.我已将所有图片发布在一个链接中,因为我的名誉似乎只能发布2个链接。
'scaleType'应该是您应该看的地方,以及图像的方向。 http://www.techrepublic.com/article/clear-up-ambiguity-about-android-image-view-scale-types-with-this-guide/这个链接应该有助于你的理解。我会为你的情况尝试“中心”。 – ElliotM
看来这将会非常有帮助。我很感激艾略特。谢谢。 – Hector25200