我的最终目标是在左对齐的水平链中放置两个单行TextView,允许它们两个生长以填充剩余空间,必要时将其均匀分割,在没有空间时进行椭圆化处理.
这是我试图完成的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
tools:text="@tools:sample/lorem"
app:layout_constrainedWidth="true"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/textView2"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:ellipsize="end"
android:maxLines="1"
tools:text="@tools:sample/lorem"
app:layout_constrainedWidth="true"
app:layout_constraintStart_toEndOf="@id/textView1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
如您所见,我在水平链中布置了两个textview.我已经将链式样式设置为打包,以便它们保持在一起.我将水平偏置设置为0,以便链条保持对齐.我已经将宽度设置为wrap_content,以便它们在文本很短时不会拉伸,并且我还设置为app:layout_constrainedWidth="true"在文本很长时它们不会越过边界.这几乎完全符合我的要求,除非 textView2中的文本增长.随着textView1的增长,它将textView2向右推,直到它达到其约束,此时它会进行椭圆化(如预期/所需),但textview2的情况也是如此.随着textView2的增长,它会延伸到右边的房间,但是一旦它达到它的约束,而不是椭圆化,它会保持拉伸并开始将textView1推向左边,直到它完全不再可见.
视觉辅助(实际行为):
我试图layout_constraintHorizontal_weight在每个视图上使用设置为.5之类的东西,但除非我将两个视图宽度都更改为0dp(match_constraints),这会破坏两个视图都有短文本的情况(它会在两个文本之间添加额外的空间)视图).
感觉就是当你结合width=wrap_content使用时layout_constrainedWidth=true,重量值会被忽略.这仅仅是ConstraintLayout的限制吗?我花了很多时间试图找到一种方法来实现这项工作,而现在它看起来似乎不太可能.我已经退回到使用LinearLayout并做出一些设计妥协,但如果有人有任何想法,我真的很想让它工作.谢谢!
android android-layout android-support-library android-constraintlayout
谷歌决定禁止通过 webview 进行 oauth 给我带来了巨大的麻烦。迁移到替代方案是一个漫长而困难的过程(我目前正在使用建议的 AppAuth 库),并且我收到用户抱怨,如果不将帐户添加到 chrome/他们的设备(这作为据我所知,如果不以某种方式强制进行私人浏览会话,现在是不可能的)。我的最新问题涉及 google oauth 登录另一个服务。这是场景:
用户想要将第三方服务链接到我的应用程序。他们在第三方服务上的帐户链接到谷歌帐户。要使用此第三方服务进行身份验证,他们必须登录其 Google 帐户。问题是第 3 方服务仅允许 http:// 方案重定向 URI 进行其 oauth,因此流程如下所示:
thirdparty帐户与我的应用程序链接http://thirdparty.com/oauththirdpartythirdparty现在thirdparty已经验证了他们的谷歌帐户thirdparty重定向到注册的redirect_uri,然后在浏览器选项卡中打开,而不是重定向回我的应用程序。问题出在第6步。因为我需要注册一个http://方案重定向 URI,所以浏览器选项卡会尝试直接加载网页,即使我已经注册了我的应用程序来处理该特定 url。现在,如果用户不需要能够使用谷歌登录,我可以轻松地在网络视图中完成整个流程并手动捕获重定向,获取令牌,但是因为thirdparty允许用户链接他们的谷歌帐户,所以我无法使用网络视图,因为谷歌会阻止用户在网络视图中执行谷歌身份验证,所以我被迫传递到我无法控制的应用程序或浏览器选项卡,并且依赖于其行为是否正确(它通常不会)
我进行了大量搜索,看起来应用程序链接可以通过将我的应用程序注册为链接的主要处理程序来解决我的问题,但这仅适用于 Android 6.0+,它高于我的设备最低版本,所以我处于我不知道自己应该在这里做什么。
我的限制是:
thirdparty)经过几个小时的搜索,我没有找到解决这个问题的单一解决方案,而且我也没有找到与 google oauth …