我有一个包含卡片列表的RecyclerView,每个卡片都扩展为子卡片.
每张卡片都有不同的文字.我希望当用户点击子卡时,它会展开以显示内部文本.扩展高度取决于卡包含的文本量.
我尝试使用以下方法测量目标高度:
view.Measure(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
Run Code Online (Sandbox Code Playgroud)
然后将卡扩展到Measured Height(参见此处).但是,它为所有卡提供相同的测量高度.
这是主适配器,它创建并绑定父卡和子卡:
public class HalachaExpandableAdapter : ExpandableRecyclerAdapter<HalachaParentViewHolder, HalachaChildViewHolder>, View.IOnClickListener
{
LayoutInflater _inflater;
bool expand;
int targetHeight;
bool wave = false;
public HalachaExpandableAdapter(Context context, List<IParentObject> itemList) : base(context, itemList)
{
_inflater = LayoutInflater.From(context);
}
public override void OnBindChildViewHolder(HalachaChildViewHolder childViewHolder, int position, object childObject)
{
var halachaChild = (HalachaChild)childObject;
childViewHolder.halachaChildTitle.Text = halachaChild.Title.ToString();
targetHeight = childViewHolder.halachaChildCard.Height;
childViewHolder.halachaChildCard.LayoutParameters.Height = 100;
childViewHolder.halachaChildCard.SetOnClickListener(this);
expand = childViewHolder.expand;
}
public override void OnBindParentViewHolder(HalachaParentViewHolder parentViewHolder, int …Run Code Online (Sandbox Code Playgroud) 我有一个RecyclerView包含CardViews TextView和a ImageView,以及其他一些布局的s .
问题是,在某些屏幕分辨率TextView下,它会被切断或推到下一行,这是我不想要的.
在其他决议中,TextView有足够的空间.
如何组织布局,以便有足够的空间TextView,并相应ImageView地调整大小?
这是我的RecyclerView项目的xml :
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:id="@+id/zmanCard"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
cardview:cardUseCompatPadding="false"
cardview:cardPreventCornerOverlap="false"
cardview:cardCornerRadius="4dp"
cardview:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical"
android:background="?attr/colorPrimaryDark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/zmanCardTitle"
android:textColor="#ffffff"
android:gravity="center"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="4dp"
android:alpha="0.8"
android:id="@+id/zmanCardImage" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="4dp">
<TextView …Run Code Online (Sandbox Code Playgroud) I try running 'npm outdated' from the console in my node project. But I get this error:
npm ERR! Cannot read property 'length' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-03-31T12_26_30_745Z-debug.log
Run Code Online (Sandbox Code Playgroud)
This is the error in the log:
199 verbose stack TypeError: Cannot read property 'length' of undefined
199 verbose stack at dotindex (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:59:32)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:11:21
199 verbose stack at Array.forEach (<anonymous>)
199 verbose stack at forEach (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:73:31) …Run Code Online (Sandbox Code Playgroud) 我正在使用自定义折叠工具栏布局,它具有标题和副标题.
我得到了倒塌的标题,并在弯曲的路径上制作动画,但由于坍塌不顺畅,标题的一部分会变小.它以锯齿状的方式调整大小.
这是我的行为,负责移动和调整标题的大小:
public class ViewBehavior : CoordinatorLayout.Behavior
{
private Context mContext;
private int mStartMarginRight;
private int mEndMargintRight;
private int mMarginLeft;
private int mStartMarginBottom;
private bool isHide;
private static float SCALE_MINIMUM = 0.5f;
public ViewBehavior(Context context, IAttributeSet attrs)
{
mContext = context;
}
public override bool LayoutDependsOn(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
{
return dependency is AppBarLayout;
}
public override bool OnDependentViewChanged(CoordinatorLayout parent, Java.Lang.Object child, View dependency)
{
ShouldInitProperties((child as HeaderView), dependency);
int maxScroll = ((AppBarLayout)dependency).TotalScrollRange;
float percentage = System.Math.Abs(dependency.GetY()) …Run Code Online (Sandbox Code Playgroud) 我试图在我的Android应用程序延迟后显示一些代码.
执行此操作的Java代码如下所示:
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
// your code that you want to delay here
}
}, 1000/* 1000ms = 1sec delay */);
Run Code Online (Sandbox Code Playgroud)
我如何使用C#在Xamarin.Android中执行此操作?
我在Angular中有一个标签组.我希望默认情况下会选择第一个选项卡.
但是,当我将其设置selectedIndex为0时,它不会选择第一个选项卡,而将其设置为1或2 会选择其他选项卡.
这是我的app.component.html:
<mat-toolbar color="primary">
<span color="white">??? ?????</span>
<span class="spacer"></span>
<button mat-icon-button>
<mat-icon class="example-icon">more_vert</mat-icon>
</button>
</mat-toolbar>
<mat-tab-group mat-stretch-tabs [selectedIndex]="0" (focusChange)="selectedTab($event)">
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>home</mat-icon>
</ng-template>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>book</mat-icon>
</ng-template>
</mat-tab>
<mat-tab>
<ng-template mat-tab-label>
<mat-icon>message</mat-icon>
</ng-template>
</mat-tab>
</mat-tab-group>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Firebase FireStore数据库在Angular 2中构建一个聊天应用程序.
我能够创建一个Collection,Docuement每个'消息' 都有一个.我使用此代码来检索消息:
export interface MessageItem {
message: string;
DateTime: Date;
User: string;
}
messagesCollection: AngularFirestoreCollection<MessageItem>;
messages: Observable<MessageItem[]>;
getChatData() {
this.messagesCollection = this.afs.collection<MessageItem>('chat_messages');
this.messages = this.messagesCollection.valueChanges();
}
Run Code Online (Sandbox Code Playgroud)
但是,因为我想要多个用户,所以我想Document为每个用户创建一个用户,这些用户存储在一个Collection消息中.
这使它变得复杂,我不确定如何完成它.
我很乐意提供一些指导.
我有一个带有标签的Android应用.我希望应用程序从右到左.
我在清单文件中放了android:supportsRtl ="true",并将一些元素改为android:layoutDirection ="rtl".
它将所有内容从右向左更改,这是我想要的,除了它反转选项卡中的滑动方向 - 当您向左滑动时,它会移动到左侧选项卡,而不是与滑动相反.我想更改它以使其成为常规滑动.
这是我的代码:
<android.support.v4.widget.DrawerLayout 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:layout_gravity="right"
android:fitsSystemWindows="true"
android:id="@+id/drawer_layout">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layoutDirection="rtl">
<include
android:id="@+id/toolbar"
android:gravity="right"
layout="@layout/toolbar" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main_layout"
android:layout_below="@id/toolbar">
<com.refractored.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:textColor="#ecf0f1"
app:pstsShouldExpand="true"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:context=".MainActivity" />
</LinearLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="@+id/nav_view"
android:layoutDirection="rtl"
app:headerLayout="@layout/header"
app:menu="@menu/nav_menu" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
希望您能够帮助我.
谢谢!
我正在构建一个应该是动态的Web表单.
当用户从列表中选择选项时,将根据其输入生成下一个表单输入.
例如:
<mat-form-field>
<mat-select placeholder="Type" [(ngModel)]="row.Type" (change)="TypeChosen(row.Type, row)">
<mat-option [value]="0">Treatment</mat-option>
<mat-option [value]="1">Travel</mat-option>
<mat-option [value]="2">Medication</mat-option>
<mat-option [value]="3">Equipment</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
如果他选择类型'治疗',他会获得另一个选择输入,其中包含一些其他输入的选项,如果他选择不同的类型,他会获得不同的选项和其他输入.
我知道我需要动态生成HTML内容,也许是动态组件.
以简单的方式做到这一点的最佳方法是什么?
我正在尝试更改 Android 中导航栏的颜色(在底部,带有后退键和主页键) - 在没有硬件主页和后退键的手机上。在我使用 Cordova 的 Ionic 应用程序中。
有没有办法做到这一点?
例子:
android ×6
xamarin ×4
angular ×3
java ×2
android-collapsingtoolbarlayout ×1
android-tabs ×1
android-xml ×1
c# ×1
cordova ×1
dom ×1
firebase ×1
html ×1
node.js ×1
npm ×1
observable ×1
tabs ×1