我需要帮助ConstraintSet.我的目标是在代码中更改视图的约束,但我无法弄清楚如何正确执行此操作.
我有4 TextView秒和1个ImageView.我需要为ImageView其中一个设置约束TextView.
check_answer4 = (TextView) findViewById(R.id.check_answer4);
check_answer1 = (TextView) findViewById(R.id.check_answer1);
check_answer2 = (TextView) findViewById(R.id.check_answer2);
check_answer3 = (TextView) findViewById(R.id.check_answer3);
correct_answer_icon = (ImageView) findViewById(R.id.correct_answer_icon);
Run Code Online (Sandbox Code Playgroud)
如果第一个答案是正确的,我需要设置的限制ImageView,以
app:layout_constraintRight_toRightOf="@+id/check_answer1"
app:layout_constraintTop_toTopOf="@+id/check_answer1"
Run Code Online (Sandbox Code Playgroud)
如果第二个答案是正确的,我需要设置的限制ImageView,以
app:layout_constraintRight_toRightOf="@+id/check_answer2"
app:layout_constraintTop_toTopOf="@+id/check_answer2"
Run Code Online (Sandbox Code Playgroud)
等等.
android android-layout android-view android-constraintlayout
我正在尝试使用Camera API创建自定义相机.我已经查看了很多类似的问题,但无论如何都无法摆脱我的相机预览中的冻结.有时候预览会在活动开始时冻结,尽管使用了其他线程.但是当我尝试切换到面部相机时,每次都会预览图像冻结.在日志我只有这样的东西:
I/Choreographer: Skipped 41 frames! The application may be doing too much work on its main thread.
Run Code Online (Sandbox Code Playgroud)
如果有问题,我的SurfaceView将放在ViewPager活动的Fragment中.
我的自定义相机类方法:
设置显示方向:
void setCameraDisplayOrientation(int cameraId) {
int rotation = getActivity().getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result = 0;
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) …Run Code Online (Sandbox Code Playgroud) 我需要在一个国家/地区中无法使用的WebView中加载一些url,因此我尝试将代理与WebView一起使用。我在SO(/sf/answers/1291736911/)上找到了一个解决方案,它可以与无需身份验证的代理一起使用。但是我需要使用用户名和密码设置代理。
有些方法没有帮助:
1)使用标头加载网址
class ProxyAuthWebViewClient extends WebViewClient {
String proxyUserName;
String proxyPassword;
public ProxyAuthWebViewClient(String proxyUserName, String proxyPassword){
this.proxyUserName = proxyUserName;
this.proxyPassword = proxyPassword;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
loadUrl(view, url, proxyUserName, proxyPassword);
return true ;
}
}
public void loadUrl(WebView view, String url, String proxyUserName, String proxyPassword){
UsernamePasswordCredentials creds= new UsernamePasswordCredentials(proxyUserName, proxyPassword);
Header credHeader = BasicScheme.authenticate(creds, "UTF-8", true);
Map<String, String> header = new HashMap<String, String>();
header.put(credHeader.getName(), credHeader.getValue());
view.loadUrl(url, header);
}
Run Code Online (Sandbox Code Playgroud)
2)在setProxy方法中添加密码和用户(以下完整代码):
Authenticator.setDefault(
new Authenticator() …Run Code Online (Sandbox Code Playgroud)