我有一个imageview,我想用Glide加载一个图像.这里的事情是,我想根据16:9的宽高比,所有图像具有相同的高度(宽度match_parent).
<ImageView
android:id="@+id/thumbImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/thumbnail_text"
android:scaleType="fitCenter"
android:src="@drawable/thumbnail_default"
android:cropToPadding="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/thumbTitle"/>
Run Code Online (Sandbox Code Playgroud)
滑动代码
Glide.with(mThumb.getContext())
.load(getThumbUrl())
.into(mThumb);
Run Code Online (Sandbox Code Playgroud)
当我加载宽高比为16:9的图像时,一切都很棒.但是,当我加载另一个图像时,高度会调整到图像的高度.
我尝试添加Constraint布局尺寸比率
app:layout_constraintDimensionRatio="16:9"
Run Code Online (Sandbox Code Playgroud)
我尝试使用adjustViewBounds和scaleType,但没有成功.
因此我认为我应该使用Glide来调整位图,然后再将其加载到imageview,但我找不到相关的教程.
如何以宽高比16:9的宽高比显示宽度match_parent和高度的图像?
谢谢,
注意:我试过了
<ImageView
android:id="@+id/thumbImage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:contentDescription="@string/thumbnail_text"
android:scaleType="centerCrop"
android:src="@drawable/thumbnail_default"
android:cropToPadding="true"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/thumbTitle"/>
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是如果方向改变了,高度就会变为0.
考虑如下的帖子内容:
[shortcode a="a_param"]
... Some content and shortcodes here
[shortcode b="b_param"]
.. Again some content here
[shortcode c="c_param"]
Run Code Online (Sandbox Code Playgroud)
我有一个接受3个或更多参数的简码。我想找出在内容及其数组中的参数中使用简码的次数,例如
array (
[0] => array(a => a_param, b=> null, c=>null),
[1] => array(a => null, b=> b_param, c=>null),
[2] => array(a => null, b=> null, c=>c_param),
)
Run Code Online (Sandbox Code Playgroud)
我需要在the_content过滤器,wp_head过滤器或类似的工具中执行此操作。
我怎样才能做到这一点 ?
谢谢,
我正在尝试使用 PHP 提取 div 的内容,而与类名和其他参数无关。
我需要的是,我有多行,单行,多参数div,例如
<div class="my-class additional-class"><div class="my-class2">
<div class="my-class"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想获得第一个 div 的所有内容,而不是第一个 div。
<div class="my-class2">
<div class="my-class"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
通常,我猜
<div.*>(.*)<\/div>/mU
Run Code Online (Sandbox Code Playgroud)
应该有效,但我不确定为什么没有。
我遇到过这个
(?s)(?<=<div\sclass="test">\n).*(?=<\/div>)
Run Code Online (Sandbox Code Playgroud)
它适用于类名,test但我无法使其工作
(?s)(?<=<div.*>\n)(.*)(?=<\/div>)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。
谢谢,