你好,我想实现一个倾斜/倾斜的图像视图或布局在android像雅虎新闻文摘应用程序中使用的。
这是我试图实现的截图
雅虎新闻文摘应用http://imageshack.com/a/img673/921/yDLbs2.png
谢谢
有两点需要注意
-
三角形形状在每个布局中都是固定的所以你必须给它拍照只有这种三角形的另一边是透明的
-
的东西,你必须可视化的三角形区域也包含新闻的类型,如(4)美国新闻然后你必须采取框架布局,其中有两个东西
- 图片(三角形)
- TextView(或显示(4)US News的布局)其余部分为线性布局。
现在你很困惑,图像将如何放置?我还有ans以
为例 <ImageView
src="image"
width="fill_parent"
height="@dimen/responsive_mesured_height"/>
<scrollView
fillviewport="true">
<LinearLayout
`orientation="vertical">
<LinearLayout
width="fill_parent"
height="@dimen/responsive_mesured_height"
background="@android:color/transperent"/>
<LinearLayout>
<!--rest of content-->
</LinearLayout>
</LinearLayout>
</LinearLayout>
</scrollview>
如果你不相信我,那就去找新闻文摘apk下载并解压。之后,在res文件夹中找到mdpi-v4文件夹,找到morning_triangle_background.png作为光主题。对于深色主题,evening_triangle_background.png
现在上面的代码是图像的视差效果,你会觉得内容是滚动的图像,就像网站。其中@dimen/responsive_mesured_height是imageview的高度(如果你想让响应,那么在所有不同的文件夹中定义不同的高度,如values,values-sw600dp,values-sw720dp,values-large(以支持lover then 3.2)等。