Guyz ... Plz帮助..给出正确的代码,因为我使用了大多数这个问题的例子,我无法解决这个问题...
我想在屏幕上显示两个视图.一个是随机定位的点位图.我可以用setContentView(...)来显示它.我还有两个位图和一个textview,它们通过xml布局语言排列,然后使用setContentView(R.layout.activity_title);
DrawV.java !!!基本上我认为我有两个setContentViews(...)我想在同一时间显示.如果您想了解更多信息,请告诉我.
公共类DrawV扩展View {VARIABES ...
public DrawV(Context context){CREATE CIRCLES(CIRELE OBJECTS)STORING COORDINATES RANDOMLY CHOSEN ......
@Override protected void onDraw(画布画布){绘制这些圆圈作为BITMAPS ...屏幕现在随机覆盖了许多点}
GameActivity.java
公共类GameActivity扩展Activity {private DrawV drawView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawView = new DrawV(this);
setContentView(R.layout.activity_title); !!!SHOWS LAYOUT (HOPEFULLY TEXTVIEW, TWO BUTTONS, AND RANDOMLY POSITIONED DOTS (DOTS NEVER WORKS) WHICH IS OVERDONE BY DRAWVIEW...
setContentView(drawView); !!!IF THIS STATEMENT IS SECOND IT RENDERS INTEAD OF THE PREVIOUS STATEMENT. OTHERWISE activity_title shows.
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
DEFAULT CODE... …Run Code Online (Sandbox Code Playgroud) 我有一个列表项,其中在LinearLayout中包含两个TextView(垂直),一个在另一个之上。较高位的数据不是静态的,我是从网络上获取的,如果数据太长,它将开始填充新行,而较低的视图将消失。因此,我想使第一个视图仅填充一行。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/margin_small">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com..view.ContactView
android:id="@+id/contact_icon"
style="@style/ContactListInitialsText"
android:layout_width="@dimen/contact_favorite_icon_size"
android:layout_height="@dimen/contact_favorite_icon_size"
app:request_photo="true"
app:show_contact_presence="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="@dimen/margin_small"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:textColor="@color/search_result_text_color"
android:textSize="16sp" />
<TextView
android:id="@+id/contact_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:textSize="12sp" />
</LinearLayout>
<CheckBox
android:id="@+id/btn_star"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:button="@drawable/btn_star_select"
android:paddingEnd="@dimen/margin_small" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 是否可以android:layoutAnimation使用Java以编程方式更改为其他动画资源?
我想要搜索图标下方的搜索文本。搜索图标+文本组应位于屏幕中央。
我想要什么:____________屏幕实际是什么样子:
注意:我使用线性布局,因为我需要直接在下面的列表视图。它将用于搜索栏。对于那些建议使用 TextView 的人android:drawableTop,我尝试过,但图像太小(即使我将图像设置为 500px),而在图像视图中将图像设置为“100dpx100dp”时也是如此。
代码
<LinearLayout 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="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/ic_search_gray_500px" />
<TextView
android:id="@+id/searchTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/search_hint"
android:layout_gravity="center_horizontal"
tools:layout_editor_absoluteX="130dp"
tools:text="@string/search_hint" />
</android.support.constraint.ConstraintLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android textview imageview android-layout android-linearlayout