我想添加ProgressBar上的顶部Button(均为内ConstraintLayout).
<Button
android:id="@+id/sign_in_button"
android:layout_width="280dp"
android:layout_height="75dp"
android:layout_marginBottom="75dp"
android:layout_marginTop="50dp"
android:text="@string/sign_in"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passwordEditText"
app:layout_constraintVertical_bias="0.0"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/sign_in_button"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="@+id/sign_in_button"
android:layout_marginBottom="8dp"
app:layout_constraintVertical_bias="0.5"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="@+id/sign_in_button"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="@+id/sign_in_button"/>
Run Code Online (Sandbox Code Playgroud)
但即使在呼吁bringToFront进入ProgressBar后onCreate,它总是留在后面Button.
ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar);
progressBar.bringToFront();
Run Code Online (Sandbox Code Playgroud) 我想根据某些条件以编程方式删除和添加约束.以下是截图:
我想删除它,但在代码中:
所以想要以编程方式实现同样的效果
这是我试过的代码:
if (advertisements.size() > 0) { //my own condition
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) btnCreateAd.getLayoutParams();
layoutParams.topToBottom = R.id.imvEmpty; //the imageview that is in center of the view
btnCreateAd.setLayoutParams(layoutParams);
recyclerView.setVisibility(View.VISIBLE);
txvMyAdEmptyText.setVisibility(View.GONE);
imvEmpty.setVisibility(View.GONE);
adapter.setList(advertisements);
adapter.notifyDataSetChanged();
} else {
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) btnCreateAd.getLayoutParams();
layoutParams.topToBottom = -1; //here i am trying to remove top constraint but it doesn't work
btnCreateAd.setLayoutParams(layoutParams);
recyclerView.setVisibility(View.GONE);
txvMyAdEmptyText.setVisibility(View.VISIBLE);
imvEmpty.setVisibility(View.VISIBLE);
adapter.setList(new ArrayList<Advertisement>());
}
mConstraintView.invalidate(); //this is my constraint view
Run Code Online (Sandbox Code Playgroud)
编辑
我也尝试过使用 ConstraintSet,但结果甚至不同,我的RecyclerView(设置为父视图的边界)正在消失
ConstraintSet set = new …Run Code Online (Sandbox Code Playgroud) android android-layout android-layoutparams android-constraintlayout
在我的应用程序中,我在CustomTabsIntent或WebView中显示外部HTML站点:
if (customTabsIntent != null) customTabsIntent.launchUrl(this, Uri.parse("http://some.where.com/site.html"));
else startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://some.where.com/site.html")));
Run Code Online (Sandbox Code Playgroud)
但该HTML的风格已经更新,但我的智能手机显示旧样式(旧字体等).
在*.html文件中有一个*.css引用:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href='https://my.site.com/assets/css/style.css' rel='stylesheet' type='text/css'>
</head>
Run Code Online (Sandbox Code Playgroud)
在那个*.css文件中,引用了一个单独的字体; 例如:
@font-face {
font-family: 'MyFontRegular';
src: url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.woff') format('woff'),
url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.eot') format('embedded-opentype');
}
Run Code Online (Sandbox Code Playgroud)
正如我所说,智能手机中的Chrome浏览器不显示引用的字体,因为它会关闭http://或https://.当我手动将该方案添加到地址栏中时,将显示正确的样式.
当我的Android应用程序调用它时,如何在我的android浏览器的地址字段中强制https://方案?
android webview android-webview chrome-custom-tabs android-customtabs
我正在使用默认的RecyclerView快速滚动,我按照本指南来支持它.
现在,问题是拇指根据数据集的大小调整其高度.对于100以上的大件物品,拇指变得非常小,几乎难以对拖动作出反应.
请问有什么方法可以为快速滚动拇指设置最小高度.
如图所示,文字不在墙上.这是一个奇怪的行为,我认为这是一个错误
这是一个屏幕截图:
这是标题xml:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:orientation="vertical">
<TextView
android:id="@+id/street_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="15dp"
android:text="street name"
android:textColor="?AppTheme.InformationText"
android:textSize="14sp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="19dp"
android:layout_marginLeft="0dp"
app:layout_constraintWidth_default="wrap"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/guideline29"
app:layout_constraintTop_toTopOf="@+id/guideline37"
app:layout_constraintRight_toLeftOf="@+id/guideline30"
app:layout_constraintHorizontal_bias="0.605"
app:layout_constraintVertical_bias="0.0"/>
<ImageView
android:id="@+id/street_view_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:padding="6dp"
android:scaleType="fitCenter"
tools:layout_constraintLeft_creator="1"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="@+id/country_flag_image"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="0dp"
app:layout_constraintRight_toLeftOf="@+id/guideline29"
android:layout_marginRight="8dp"
app:layout_constraintTop_toTopOf="@+id/guideline37"
android:layout_marginTop="8dp"/>
<ImageView
android:id="@+id/country_flag_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintLeft_creator="1"
tools:layout_constraintTop_creator="1"
/>
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/exit_image"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="-4dp"
android:src="@drawable/exit_custom"
app:border_color="#FF000000"
app:layout_constraintBottom_toBottomOf="@+id/street_view_image"
app:layout_constraintRight_toRightOf="@+id/street_view_image"
tools:layout_constraintBottom_creator="1"
tools:layout_constraintRight_creator="1"
/>
<android.support.constraint.Guideline
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 下面Canvas没有在android 28中找到的变量.
canvas.saveLayer(0, 0, getWidth(), getHeight(), null,
Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
Run Code Online (Sandbox Code Playgroud) 自从转换到ConstraintLayout版本1.1.0-beta4后,我的几个布局都爆炸了.在进行任何更改之前,我希望更好地了解利润率如何在ConstraintLayout链条中发挥作用.在下文中,我将ConstraintLayout版本1.0.2中的布局与版本1.1.0-beta4进行比较,但我认为该问题首先出现在1.1.0-beta2中.
我的目标是让一些文本视图在屏幕上伸展,第一和第二文本视图之间以及第二和第三文本视图之间存在间隙.背景应显示在这些边距中.为此,我创建一个水平链并指定从左侧文本视图到中心文本视图的结束边距以及从中心文本视图到右侧文本视图的结束边距.横向链式是spread_inside.
示例1 - 使用ConstraintLayout 1.0.2版
这就是版本1.0.2中的内容,并且是我所期望的.
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/holo_blue_light">
<TextView
android:id="@+id/tvLeft"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_marginEnd="8dp"
android:background="@android:color/white"
android:gravity="center"
android:text="Text1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvCenter"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvCenter"
android:layout_width="0dp"
android:layout_height="35dp"
android:layout_marginEnd="8dp"
android:background="@android:color/white"
android:gravity="center"
android:text="Text2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tvRight"
app:layout_constraintStart_toEndOf="@+id/tvLeft"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tvRight"
android:layout_width="0dp"
android:layout_height="35dp"
android:background="@android:color/white"
android:gravity="center"
android:text="Text3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tvCenter"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
示例2 - 使用ConstraintLayout版本1.1.0-beta4
这个相同的布局在版本1.1.0-beta4中如下所示ConstraintLayout.请注意,边距已消失.我希望这看起来与示例1相同,但事实并非如此.
示例3 - 使用带有起始边距的ConstraintLayout版本1.1.0-beta4
如果我采用相同的布局并简单地8dp向右侧文本视图添加一个开始边距(tvRight),我的边距不仅会重新出现在中间和右侧文本视图之间,还会出现在左侧和中间文本视图之间,尽管我没有更改边距.
这不仅仅是之前设定的利润突然被尊重.如果我将最右边文本视图的起始边距设置为"48dp",48dp则左侧和中心文本视图之间也会显示边距.
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="50dp" …Run Code Online (Sandbox Code Playgroud) 自Google I/O宣布之后不久,我一直在使用新的导航组件,并且也开始尽可能地接受单项活动.
单一活动允许我在视图之间共享ViewModel以获得非常棒的体验,如果我没有被迫,我真的不想回到多活动.
但是有一些东西阻碍了:AppBar/Themes(状态栏)到单一活动的概念.
这是我正在进行的设计的一部分:
正如您所看到的,Actionbar /状态栏的外观有不同的要求.
CollapsingToolbarLayout在向上滚动时应该用于变成标准动作栏离开单项活动所产生的问题清单:
ViewModel在活动之间分享如果可能的话,这些是我想要避免的问题,但是你们如何在导航组件的单一活动中管理这些情况.任何的想法?
android-layout android-fragments android-architecture-navigation
我们的自定义设备可在Android操作系统上运行,但未包含Google Play服务.
我们使用Webview Oauth2.0身份验证进行Google登录.根据文件,它已被删除.
我读到有一种方式https://developers.google.com/identity/sign-in/android/,但这似乎需要gradle合并游戏服务.
那么我可以使用哪种方式进行谷歌身份验证?
我找到了两个选项如下,但它们对我的情况有帮助吗?
1. https://firebase.google.com/docs/auth/android/start/
2. https://developers.google.com/api-client-library/java/google-api-java-client/oauth2
哪个可能是最适合我的要求
请帮助.
此致,
Shraddha
通常,活动将显示最大屏幕.我希望显示一个宽度为400px,高度为500px的窗口,但是下面仍然显示一个完整的窗口,为什么?
主要活动
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
Run Code Online (Sandbox Code Playgroud)
activity_main.xml中
<?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="400px"
android:layout_height="500px"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World OK!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
到克柳月
谢谢!但是你的代码不起作用,运行代码后窗口全屏显示.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val m = windowManager
val d = m.defaultDisplay
val p = window.attributes
p.height = dp2px(this, 500f)
p.width = dp2px(this, 400f)
window.attributes = p
}
private fun dp2px(context: Context, …Run Code Online (Sandbox Code Playgroud) android ×9
webview ×2
android-architecture-navigation ×1
canvas ×1
google-oauth ×1
oauth-2.0 ×1
textview ×1