我正在处理我在选项卡上设置的两个片段。
我有两个问题:
这是添加片段并设置其标题的代码
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new OneFragment(), "Current\nSubscription");
Run Code Online (Sandbox Code Playgroud)
如何在Android中实现以下垂直布局?
View1
View2
View3
Run Code Online (Sandbox Code Playgroud)
所有三个视图都具有适合屏幕的宽度.
View2高度是固定的(= 100).
View1高度等于view3's高度.
我能够有实现这一目标LinearLayout,RelativeLayout,ConstraintLayout?
如果有一个程序化的解决方案,而不是XML布局,我会很感激.
在我的XML文件中,我有一个ConstaintLayout。那里我有ImageView这个设置:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@+id/game_square"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_game_quadrat"
android:visibility="invisible"
android:id="@+id/game_right"/>
Run Code Online (Sandbox Code Playgroud)
如何访问app:layout_constraintHorizontal_bias =“ 1”上的java文件,将其更改为例如0。
莫里兹
我EditText有一些颜色,但是当我输入一些文本时,它应该会改变。说它是灰色,我开始输入,它是黄色。这EditText也是重点,因此当此活动开始时-我已经可以输入文本了。我如何尝试:
<style name="LoginEnterField">
<item name="android:textColorHint">@color/black</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@drawable/selector_edittext</item>
<item name="android:textSize">@dimen/general_text_size</item>
<item name="android:paddingLeft">@dimen/activity_inner_horizontal_margin</item>
<item name="android:paddingRight">@dimen/activity_inner_horizontal_margin</item>
</style>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/grey"/>
<corners android:radius="5dp" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/yellow"/>
<corners android:radius="5dp" />
</shape>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@drawable/roundbox_active_style"/>
<item android:drawable="@drawable/roundbox_inactive_style" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我认为关键在于此选择器。我的EditText更改颜色,但始终为黄色。仅当输入一些文字时,如何使其变成黄色?我无法进行任何代码更改!这很重要。我不能仅添加或更改xml文件。
编辑:这是不可能只从xml,所以进行代码更改。
我正在使用tabLayout我的应用中的标签。我想更改所选标签的背景颜色和文本颜色。我正在tabLayout通过这样做来更改整个背景的颜色
android:background="@color/colorAccent"
Run Code Online (Sandbox Code Playgroud)
并更改textcolor和selectedtextcolor
app:tabTextColor="#000000"
app:tabSelectedTextColor="@color/colorAccent"
Run Code Online (Sandbox Code Playgroud)
但是我现在要做的就是在选中该特定选项卡时更改其背景颜色?怎么做 ?提前致谢 :)