我在 listView 中有一个 YoutubeThumbnail/ImageView,我想填充/拉伸(stretch)到屏幕边缘:
<com.example.project.ui.widget.VideosListView
android:id="@+id/videosListView"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
和
<com.example.project.ui.widget.UrlImageView
android:id="@+id/userVideoThumbImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:scaleType="fitXY"
android:clickable="false"
android:contentDescription="YouTube video thumbnail"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:src="@drawable/ic_launcher" />
目前它似乎并没有这样做,而且在某些设备上,缩略图看起来很小。
我不确定我究竟做错了什么 - 任何输入都将受到赞赏。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
<ListView
android:id="@+id/left_drawer"
android:layout_width="120dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/darkgrey"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AAFFFFFF" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.example.project.ui.widget.VideosListView
android:id="@+id/videosListView"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true" >
<ImageButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@color/darkgrey"
android:scaleType="centerCrop"
android:src="@drawable/home_up_btn" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
>
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageButton
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:focusable="false"
android:src="@drawable/scroll_lt_arrow" />
<ImageButton
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:focusable="false"
android:src="@drawable/scroll_rt_arrow" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
<?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" >
<com.example.project.ui.widget.UrlImageView
android:id="@+id/userVideoThumbImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@android:color/black"
android:scaleType="fitXY"
android:clickable="false"
android:contentDescription="YouTube video thumbnail"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:src="@drawable/ic_launcher" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="invisible" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/userVideoTitleTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:text="Video Title Not Found"
android:textColor="@android:color/black"
android:textSize="20sp" />
<Button
android:id="@+id/fav_up_btn1"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_alignParentRight="true"
android:background="@drawable/fav_up_btn1"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="right"
android:paddingRight="5dp"
android:paddingTop="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/userVideouploaderTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:textColor="@color/verylightgrey"
android:textSize="16sp" />
<TextView
android:id="@+id/userVideoviewsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/userVideouploaderTextView"
android:textColor="@android:color/black"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
private VideosListView listView;
listView = (VideosListView) findViewById(R.id.videosListView);
listView.setOnVideoClickListener(this);
private void populateListWithVideos(Message msg) {
Library lib = (Library) msg.getData().get(
GetYouTubeUserVideosTask.LIBRARY);
listView.setVideos(lib.getVideos());
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.idg.omv.ui.widget.UrlImageView
android:id="@+id/userVideoThumbImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="false"
android:background="@android:color/black"
android:clickable="false"
android:contentDescription="YouTube video thumbnail"
android:focusable="false"
android:focusableInTouchMode="false"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:visibility="invisible" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/userVideoTitleTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:text="Video Title Not Found"
android:textColor="@android:color/black"
android:textSize="20sp" />
<Button
android:id="@+id/fav_up_btn1"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_alignParentRight="true"
android:background="@drawable/fav_up_btn1"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="right"
android:paddingRight="5dp"
android:paddingTop="5dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/userVideouploaderTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:textColor="@color/verylightgrey"
android:textSize="16sp" />
<TextView
android:id="@+id/userVideoviewsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/userVideouploaderTextView"
android:textColor="@android:color/black"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
最佳答案
如果您要扩展 ImageView,请尝试应用它:
android:scaleType="fitXY"
或者在javacode中
imageView.setScaleType(ScaleType.FIT_XY);
2) 应用上面提到的代码,如:
<com.example.project.ui.widget.UrlImageView
android:id="@+id/userVideoThumbImageView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="false"
android:background="@android:color/black"
android:clickable="false"
android:contentDescription="YouTube video thumbnail"
android:focusable="false"
android:scaleType="fitXY"
android:focusableInTouchMode="false"
android:gravity="center"
android:src="@drawable/ic_launcher" />
编辑更改:
android:adjustViewBounds="true"
到
android:adjustViewBounds="false"
关于android - match_parent 并且未按预期填充 - Android/XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20687530/
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
我有一个驼峰式字符串,例如:JustAString。我想按照以下规则形成长度为4的字符串:抓取所有大写字母;如果超过4个大写字母,只保留前4个;如果少于4个大写字母,则将最后大写字母后的字母大写并添加字母,直到长度变为4。以下是可能发生的3种情况:ThisIsMyString将产生TIMS(大写字母);ThisIsOneVeryLongString将产生TIOV(前4个大写字母);MyString将生成MSTR(大写字母+tr大写)。我设法用这个片段解决了前两种情况:str.scan(/[A-Z]/).first(4).join但是,我不太确定如何最好地修改上面的代码片段以处理最后一种
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我在使用Rails3.0.2时遇到了这个奇怪的错误。ActionView::Template::Error(undefinedmethod`parent'fornil:NilClass):app/controllers/channels_controller.rb:19:in`index'这是Controller,19行是respond_with(@channels)block。我从哪里开始搜索错误?classChannelsController这是完整的错误:ActionView::Template::Error(undefinedmethod`parent'fornil:NilCl
我正在尝试解决http://projecteuler.net/problem=1.我想创建一个方法,它接受一个整数,然后创建一个包含它前面的所有整数的数组,并将整数本身作为数组中的值。以下是我目前所拥有的。代码不起作用。defmake_array(num)numbers=Array.newnumcount=1numbers.eachdo|number|numbers 最佳答案 (1..num).to_a是您在Ruby中需要做的全部。1..num将创建一个Range对象,以1开始并以任意值num结束是。Range对象有to_a方法通过
这段代码没有像我预期的那样执行:casewhen->{false}then"why?"else"ThisiswhatIexpect"end#=>"why?"这也不是casewhen->(x){false}then"why?"else"ThisiswhatIexpect"end#=>"why?"第一个then子句在两种情况下都被执行,这意味着我提供给when子句的lambda没有被调用。我知道无论when子句的主题是什么,都应该调用大小写相等运算符===。我想知道当没有为case提供参数时,===的另一边会发生什么。我在想它可能是nil,但它不可能是:->{false}===nil#=>
如果我想要“00001”而不是“1”,除了我自己写填零方法之外,有没有内置的方法可以帮助我为整数填零? 最佳答案 puts"%05d"%1#00001参见:String::%,Kernel::sprintf这是正在发生的事情。%左侧的"%05d"是C风格的格式说明符。%右边的变量就是要格式化的东西。格式说明符可以像这样解码:%-格式说明符的开头0-用前导零填充5-长度为5个字符d-被格式化的是一个整数如果你要格式化多个东西,你会把它们放在一个数组中:"%d-%s"%[1,"One"]#=>1-one
我正在尝试使用Sinatra中的重定向和session在网站周围传递一些数据。这是一个简化的示例,使用PrettyPrint进行调试:require'pp'require'rubygems'require'sinatra'enable:sessionsget'/'dosession[:foo]='12345'puts'session1'ppsessionredirectto('/redir')endget'/redir'doputs'session2'ppsession'helloworld'end查看Thin的输出,我看到:>>Listeningon0.0.0.0:4567,CTRL
我想禁用HTTP参数的自动XML解析。但我发现命令仅适用于Rails2.x,它们都不适用于3.0:config.action_controller.param_parsers.deleteMime::XML(application.rb)ActionController::Base.param_parsers.deleteMime::XMLRails3.0中的等价物是什么? 最佳答案 根据CVE-2013-0156的最新安全公告你可以将它用于Rails3.0。3.1和3.2ActionDispatch::ParamsParser::